增加我的奖品页面,兑换页面
1
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
/unpackage/
|
||||
/test/
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
"version" : "1.0",
|
||||
"configurations" : [
|
||||
{
|
||||
"app-plus" : {
|
||||
"launchtype" : "local"
|
||||
},
|
||||
"default" : {
|
||||
"launchtype" : "local"
|
||||
},
|
||||
@@ -13,6 +16,10 @@
|
||||
},
|
||||
"provider" : "aliyun",
|
||||
"type" : "uniCloud"
|
||||
},
|
||||
{
|
||||
"playground" : "custom",
|
||||
"type" : "uni-app:app-android"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
1
App.vue
@@ -798,4 +798,5 @@
|
||||
@import "uview-ui/index.scss";
|
||||
@import 'components/colorui/main.css';
|
||||
@import 'components/colorui/icon.css';
|
||||
@import '@/common/style/common.scss';
|
||||
</style>
|
||||
409
common/style/common.scss
Normal file
@@ -0,0 +1,409 @@
|
||||
.u-relative,
|
||||
.u-rela {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.u-absolute,
|
||||
.u-abso {
|
||||
position: absolute;
|
||||
}
|
||||
.u-fixed,.u-fix{
|
||||
position: fixed;
|
||||
}
|
||||
.left-top{
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
.u-overflow-hide{
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
// nvue不能用标签命名样式,不能放在微信组件中,否则微信开发工具会报警告,无法使用标签名当做选择器
|
||||
/* #ifndef APP-NVUE */
|
||||
image {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
// 在weex,也即nvue中,所有元素默认为border-box
|
||||
view,
|
||||
text {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
/* #endif */
|
||||
|
||||
.u-font-xs {
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.u-font-sm {
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.u-font-md {
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.u-font-lg {
|
||||
font-size: 30rpx;
|
||||
}
|
||||
|
||||
.u-font-xl {
|
||||
font-size: 34rpx;
|
||||
}
|
||||
|
||||
.u-flex {
|
||||
/* #ifndef APP-NVUE */
|
||||
display: flex;
|
||||
/* #endif */
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.u-flex-wrap {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.u-flex-nowrap {
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
.u-col-center {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.u-col-top {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.u-col-bottom {
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.u-row-center {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.u-row-left {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.u-row-right {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.u-row-between {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.u-row-around {
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
.u-text-left {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.u-text-center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.u-text-right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.u-flex-col {
|
||||
/* #ifndef APP-NVUE */
|
||||
display: flex!important;
|
||||
/* #endif */
|
||||
flex-direction: column!important;
|
||||
}
|
||||
|
||||
// 定义flex等分
|
||||
@for $i from 0 through 12 {
|
||||
.u-flex-#{$i} {
|
||||
flex: $i;
|
||||
}
|
||||
}
|
||||
|
||||
// 定义字体(px)单位,小于20都为px单位字体
|
||||
@for $i from 9 to 20 {
|
||||
.u-font-#{$i} {
|
||||
font-size: $i + px;
|
||||
}
|
||||
}
|
||||
|
||||
// 定义字体(rpx)单位,大于或等于20的都为rpx单位字体
|
||||
@for $i from 20 through 40 {
|
||||
.u-font-#{$i} {
|
||||
font-size: $i + rpx;
|
||||
}
|
||||
}
|
||||
|
||||
// 定义内外边距,历遍1-80
|
||||
@for $i from 0 through 80 {
|
||||
// 只要双数和能被5除尽的数
|
||||
@if $i % 2 == 0 or $i % 5 == 0 {
|
||||
// 得出:u-margin-30或者u-m-30
|
||||
.u-margin-#{$i}, .u-m-#{$i} {
|
||||
margin: $i + rpx!important;
|
||||
}
|
||||
|
||||
// 得出:u-padding-30或者u-p-30
|
||||
.u-padding-#{$i}, .u-p-#{$i} {
|
||||
padding: $i + rpx!important;
|
||||
}
|
||||
|
||||
@each $short, $long in l left, t top, r right, b bottom {
|
||||
// 缩写版,结果如: u-m-l-30
|
||||
// 定义外边距
|
||||
.u-m-#{$short}-#{$i} {
|
||||
margin-#{$long}: $i + rpx!important;
|
||||
}
|
||||
|
||||
// 定义内边距
|
||||
.u-p-#{$short}-#{$i} {
|
||||
padding-#{$long}: $i + rpx!important;
|
||||
}
|
||||
|
||||
// 完整版,结果如:u-margin-left-30
|
||||
// 定义外边距
|
||||
.u-margin-#{$long}-#{$i} {
|
||||
margin-#{$long}: $i + rpx!important;
|
||||
}
|
||||
|
||||
// 定义内边距
|
||||
.u-padding-#{$long}-#{$i} {
|
||||
padding-#{$long}: $i + rpx!important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 重置nvue的默认关于flex的样式
|
||||
.u-reset-nvue {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* start--文本行数限制--start */
|
||||
.u-line-1 {
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.u-line-2 {
|
||||
-webkit-line-clamp: 2;
|
||||
}
|
||||
|
||||
.u-line-3 {
|
||||
-webkit-line-clamp: 3;
|
||||
}
|
||||
|
||||
.u-line-4 {
|
||||
-webkit-line-clamp: 4;
|
||||
}
|
||||
|
||||
.u-line-5 {
|
||||
-webkit-line-clamp: 5;
|
||||
}
|
||||
|
||||
.u-line-2, .u-line-3, .u-line-4, .u-line-5 {
|
||||
overflow: hidden;
|
||||
word-break: break-all;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box; // 弹性伸缩盒
|
||||
-webkit-box-orient: vertical; // 设置伸缩盒子元素排列方式
|
||||
}
|
||||
|
||||
/* end--文本行数限制--end */
|
||||
|
||||
|
||||
/* start--不同颜色文字--start */
|
||||
.color-333{
|
||||
color: #333;
|
||||
}
|
||||
.color-666{
|
||||
color: #666;
|
||||
}
|
||||
.color-999{
|
||||
color: #999;
|
||||
}
|
||||
.color-red{
|
||||
color: $my-red-color;
|
||||
}
|
||||
.color-main{
|
||||
color:$my-main-color
|
||||
}
|
||||
|
||||
/* end--不同颜色文字--end */
|
||||
|
||||
|
||||
.tranistion{
|
||||
transition: all .3s ease-in-out;
|
||||
}
|
||||
.tranistion-1{
|
||||
transition: all .1s ease-in-out;
|
||||
}
|
||||
.tranistion-2{
|
||||
transition: all .2s ease-in-out;
|
||||
}
|
||||
.font-bold{
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
|
||||
/* start--不同颜色背景--start */
|
||||
.my-bg-main{
|
||||
background-color:$my-main-color
|
||||
}
|
||||
|
||||
/* end--不同颜色背景--end */
|
||||
|
||||
.safe-page{
|
||||
padding-bottom: 60rpx!important;
|
||||
}
|
||||
::v-deep .uni-switch-input.uni-switch-input-checked{
|
||||
border-color: $my-main-color;
|
||||
background-color: $my-main-color;
|
||||
}
|
||||
.btn-circle{
|
||||
border-radius: 200px;
|
||||
}
|
||||
.min-page{
|
||||
/* #ifdef H5 */
|
||||
min-height: calc(100vh - 44px);
|
||||
/* #endif */
|
||||
/* #ifndef H5 */
|
||||
min-height: 100vh;
|
||||
/* #endif */
|
||||
}
|
||||
.w-full{
|
||||
width: 100%;
|
||||
}
|
||||
.gap-20{
|
||||
gap: 20rpx;
|
||||
}
|
||||
.color-000{
|
||||
color: #000;
|
||||
}
|
||||
.color-fff{
|
||||
color: #fff;
|
||||
}
|
||||
.bg-fff{
|
||||
background-color: #fff;
|
||||
}
|
||||
.bg-gray{
|
||||
background-color: #F9F9F9;
|
||||
}
|
||||
.overflow-hide{
|
||||
/* #ifdef H5 */
|
||||
height: calc(100vh - 44px);
|
||||
/* #endif */
|
||||
/* #ifndef H5 */
|
||||
height: 100vh;
|
||||
/* #endif */
|
||||
overflow: hidden;
|
||||
}
|
||||
.no-wrap{
|
||||
white-space: nowrap;
|
||||
}
|
||||
.border-r-12{
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
.border-r-18{
|
||||
border-radius: 18rpx;
|
||||
}
|
||||
.border-top{
|
||||
border-top: 1px solid #E5E5E5;
|
||||
}
|
||||
.border-bottom{
|
||||
border-bottom: 1px solid #E5E5E5;
|
||||
}
|
||||
.scale7{
|
||||
transform: scale(0.7);
|
||||
}
|
||||
.page-gray {
|
||||
min-height: calc(100vh);
|
||||
/* #ifdef H5 */
|
||||
min-height: calc(100vh - var(--window-top));
|
||||
/* #endif */
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: #F9F9F9;
|
||||
}
|
||||
.box-shadow{
|
||||
box-shadow: 0 0 5px #eee;
|
||||
}
|
||||
.safe-bottom{
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
/* #ifdef H5 */
|
||||
padding-bottom: 28rpx;
|
||||
/* #endif */
|
||||
}
|
||||
.position-all{
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
.fixed-top{
|
||||
position: fixed;
|
||||
/* #ifdef H5 */
|
||||
top: 44px;
|
||||
/* #endif */
|
||||
/* #ifndef H5 */
|
||||
top: 0;
|
||||
/* #endif */
|
||||
left: 0;
|
||||
right: 0;
|
||||
}
|
||||
.lh30 {
|
||||
line-height: 30px;
|
||||
}
|
||||
.default-box-padding{
|
||||
padding: 32rpx 24rpx;
|
||||
}
|
||||
.icon-arrow-down-fill {
|
||||
width: 16rpx;
|
||||
height: 10rpx;
|
||||
}
|
||||
.zIndex-999{
|
||||
z-index: 999;
|
||||
}
|
||||
.icon-default-size{
|
||||
width: 28rpx;
|
||||
height: 28rpx;
|
||||
}
|
||||
::v-deep.uni-easyinput__placeholder-class{
|
||||
font-size: 28rpx!important;
|
||||
}
|
||||
.filter-gray{
|
||||
filter: grayscale(1);
|
||||
}
|
||||
// .u-font-20{
|
||||
// font-size: 10px;
|
||||
// }
|
||||
// .u-font-24{
|
||||
// font-size: 12px;
|
||||
// }
|
||||
// .u-font-28{
|
||||
// font-size: 14px;
|
||||
// }
|
||||
// .u-font-32{
|
||||
// font-size: 16px;
|
||||
// }
|
||||
.line-th{
|
||||
text-decoration: line-through;
|
||||
}
|
||||
//覆盖u-view-plus 颜色
|
||||
.u-primary-light {
|
||||
color: $my-main-color;
|
||||
}
|
||||
::v-deep .u-border{
|
||||
border-width: 1px!important;
|
||||
}
|
||||
|
||||
::v-deep .u-m-t-16 .u-textarea{
|
||||
border-width: 1px!important;
|
||||
}
|
||||
BIN
key/certificate.cer
Normal file
1
key/readme.md
Normal file
@@ -0,0 +1 @@
|
||||
vMLdZb1r
|
||||
BIN
key/video.keystore
Normal file
709
me/choujiang/choujiang.vue
Normal file
@@ -0,0 +1,709 @@
|
||||
<template>
|
||||
<view class="almost-lottery">
|
||||
<!-- head -->
|
||||
<view class="almost-lottery__head">
|
||||
|
||||
|
||||
<!-- <view :class="['action', isApple && 'action-shadow']">
|
||||
<text class="gold"></text>
|
||||
<text class="content">红包余额:<text class="num">{{ goldCoin }}</text></text>
|
||||
</view> -->
|
||||
<view class="btn-group u-flex u-row-between">
|
||||
<view :class="['action', isApple && 'action-shadow']">
|
||||
<text class="pack"></text>
|
||||
<text class="content">红包余额:<text class="num">{{ goldCoin }}</text></text>
|
||||
</view>
|
||||
<view :class="['action', isApple && 'action-shadow']" @click="toGift">
|
||||
<text class="gift"></text>
|
||||
<text class="content">我的奖品</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view class="tip"><text class="tip-content">每次抽奖消耗 {{ goldNum }} 金币,不限次数</text></view> -->
|
||||
</view>
|
||||
<!-- action -->
|
||||
|
||||
<!-- <view class="almost-lottery__action-dev" @tap="handleInitCanvas" v-if="isDev">
|
||||
<text class="text">重新生成画板-开发模式使用</text>
|
||||
</view>
|
||||
<view class="almost-lottery__action-dev" @tap="handleCheckPopup">
|
||||
<text class="text">查看 uni-popup 用例</text>
|
||||
</view> -->
|
||||
|
||||
<!-- lottery -->
|
||||
<view class="almost-lottery__wheel">
|
||||
<almost-lottery :lottery-size="lotteryConfig.lotterySize" :action-size="lotteryConfig.actionSize"
|
||||
:ring-count="2" :duration="1" :self-rotaty="false" :img-circled="true" :canvasCached="true"
|
||||
:prize-list="prizeList" :prize-index="prizeIndex" :lotteryBg="lotteryBg" :actionBg="actionBg"
|
||||
@reset-index="prizeIndex = -1" @draw-before="handleDrawBefore" @draw-start="handleDrawStart"
|
||||
@draw-end="handleDrawEnd" @finish="handleDrawFinish" v-if="prizeList.length" />
|
||||
<view class="almost-lottery__count">
|
||||
<text class="text">剩余免费抽奖 {{ freeNum }} 次</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- rule -->
|
||||
<view class="almost-lottery__rule">
|
||||
<view class="rule-head">
|
||||
<view class="line"></view>
|
||||
<text class="title">活动规则</text>
|
||||
<view class="line"></view>
|
||||
</view>
|
||||
<view class="rule-body">
|
||||
<view class="item">
|
||||
<view class="number">1</view>
|
||||
<view class="text">
|
||||
<text>抽奖细则:</text>
|
||||
<text>每人每天拥有{{ freeNumDay }}次抽奖机会,每次消耗{{ goldNum }}金币。</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="item item-rule">
|
||||
<view class="number">2</view>
|
||||
<view class="text">
|
||||
<text>奖励说明:</text>
|
||||
<text>a.现金奖:系统会即时转入账户余额,可提现。</text>
|
||||
<!-- <text>b.金币奖:系统会即时转入金币账户,可在平台内使用。</text> -->
|
||||
<text>b.实物奖:中奖后需联系客服领取。</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <template >
|
||||
<view class="item">
|
||||
<view class="number">3</view>
|
||||
<view class="text">本次活动由XXXXXXX发起。</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
<view class="number">4</view>
|
||||
<view class="text">本活动仅限17岁以上用户参加。</view>
|
||||
</view>
|
||||
<view class="item">
|
||||
<view class="number">5</view>
|
||||
<view class="text">本活动最终解释权归XXXXXXX所有。</view>
|
||||
</view>
|
||||
</template> -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import AlmostLottery from '@/uni_modules/almost-lottery/components/almost-lottery/almost-lottery.vue'
|
||||
import {
|
||||
clearCacheFile,
|
||||
clearStore
|
||||
} from '@/uni_modules/almost-lottery/utils/almost-utils.js'
|
||||
export default {
|
||||
name: 'Home',
|
||||
components: {
|
||||
AlmostLottery
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 开启调试模式
|
||||
isDev: true,
|
||||
option:{},
|
||||
// 以下是转盘配置相关数据
|
||||
lotteryConfig: {
|
||||
// 抽奖转盘的整体尺寸,单位rpx
|
||||
lotterySize: 600,
|
||||
// 抽奖按钮的尺寸,单位rpx
|
||||
actionSize: 200
|
||||
},
|
||||
|
||||
// 以下是转盘 UI 配置
|
||||
// 转盘外环图,如有需要,请参考替换为自己的设计稿
|
||||
lotteryBg: require('@/uni_modules/almost-lottery/static/almost-lottery/almost-lottery__bg2x.png'),
|
||||
// 抽奖按钮图
|
||||
actionBg: require('@/uni_modules/almost-lottery/static/almost-lottery/almost-lottery__action2x.png'),
|
||||
|
||||
// 以下是奖品配置数据
|
||||
// 奖品数据
|
||||
prizeList: [],
|
||||
// 奖品是否设有库存
|
||||
onStock: true,
|
||||
// 中奖下标
|
||||
prizeIndex: -1,
|
||||
|
||||
// 是否正在抽奖中,避免重复触发
|
||||
prizeing: false,
|
||||
|
||||
// 以下为中奖概率有关数据
|
||||
// 是否由前端控制概率,默认不开启,强烈建议由后端控制
|
||||
onFrontend: false,
|
||||
// 权重随机数的最大值
|
||||
prizeWeightMax: 0,
|
||||
// 权重数组
|
||||
prizeWeightArr: [],
|
||||
|
||||
// 以下为业务需求有关示例数据
|
||||
// 金币余额
|
||||
goldCoin: 20,
|
||||
// 当日免费抽奖次数余额
|
||||
freeNum: 1,
|
||||
// 每次消耗的金币数
|
||||
goldNum: 20,
|
||||
// 每天免费抽奖次数
|
||||
freeNumDay: 1
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isApple() {
|
||||
return uni.getSystemInfoSync().platform === 'ios'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
toGift() {
|
||||
console.log('1');
|
||||
uni.navigateTo({
|
||||
url: '/me/gift/gift'
|
||||
})
|
||||
},
|
||||
// 重新生成
|
||||
handleInitCanvas() {
|
||||
clearCacheFile()
|
||||
clearStore()
|
||||
|
||||
this.prizeList = []
|
||||
this.getPrizeList()
|
||||
},
|
||||
// 通过 popup 打开
|
||||
handleCheckPopup() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/popup/popup'
|
||||
})
|
||||
},
|
||||
// 获取奖品列表
|
||||
async getPrizeList() {
|
||||
uni.showLoading({
|
||||
title: '奖品准备中...'
|
||||
})
|
||||
|
||||
// 等待接口返回的数据进一步处理
|
||||
let res = await this.requestApiGetPrizeList()
|
||||
console.log('获取奖品列表', res)
|
||||
|
||||
if (res.ok) {
|
||||
let data = res.data
|
||||
if (data.length) {
|
||||
this.prizeList = data
|
||||
console.log('已获取到奖品列表数据,开始绘制抽奖转盘')
|
||||
|
||||
// 计算开始绘制的时间
|
||||
if (console.time) {
|
||||
console.time('绘制转盘用时')
|
||||
}
|
||||
|
||||
// 如果开启了前端控制概率
|
||||
// 得出权重的最大值并生成权重数组
|
||||
if (this.onFrontend) {
|
||||
// 生成权重数组并排序取得最大值
|
||||
this.prizeWeightArr = this.prizeList.map(item => item.prizeWeight)
|
||||
let prizeWeightArrSort = [...this.prizeWeightArr]
|
||||
prizeWeightArrSort.sort((a, b) => b - a)
|
||||
|
||||
// 开放自定义权重最大值,没有自定义则取权重数组中的最大值
|
||||
this.prizeWeightMax = this.prizeWeightMax > 0 ? this.prizeWeightMax : prizeWeightArrSort[0]
|
||||
}
|
||||
}
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '获取奖品失败',
|
||||
mask: true,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
// 模拟请求 获取奖品列表 接口,
|
||||
// 注意这里返回的是一个 Promise
|
||||
// 大哥,这里只是模拟,别告诉我你不会对接自己的接口
|
||||
async requestApiGetPrizeList() {
|
||||
const res = await this.$Request.getT('/app/discSpinning/selectDiscSpinning')
|
||||
if (res.code == 0) {
|
||||
return {
|
||||
ok: true,
|
||||
data: res.data.records.map(v => {
|
||||
return {
|
||||
prizeId: v.id,
|
||||
prizeName: v.name,
|
||||
prizeStock: 10,
|
||||
prizeWeight: 200,
|
||||
prizeImage: v.url,
|
||||
// prizeImage: require('@/static/git.png')
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
return
|
||||
return new Promise((resolve, reject) => {
|
||||
let requestTimer = setTimeout(() => {
|
||||
clearTimeout(requestTimer)
|
||||
requestTimer = null
|
||||
|
||||
// prizeStock 奖品库存
|
||||
// prizeWeight 中奖概率,数值越大中奖概率越高,权重一样时随机中奖
|
||||
resolve({
|
||||
ok: true,
|
||||
data: [{
|
||||
prizeId: 1,
|
||||
prizeName: '0.1元现金',
|
||||
prizeStock: 10,
|
||||
prizeWeight: 200,
|
||||
prizeImage: require('@/static/git.png')
|
||||
},
|
||||
{
|
||||
prizeId: 2,
|
||||
prizeName: '10元现金',
|
||||
prizeStock: 0,
|
||||
prizeWeight: 50,
|
||||
prizeImage: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/56f085e0-bcfe-11ea-b244-a9f5e5565f30.png'
|
||||
},
|
||||
{
|
||||
prizeId: 3,
|
||||
prizeName: '5元话费',
|
||||
prizeStock: 1,
|
||||
prizeWeight: 80
|
||||
},
|
||||
{
|
||||
prizeId: 4,
|
||||
prizeName: '50元现金',
|
||||
prizeStock: 0,
|
||||
prizeWeight: 10,
|
||||
prizeImage: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAYAAADE6YVjAAAB2klEQVRIia3Wv09TURjG8U+u2kQZcNENh2ok0cnJ0R+L0RB2g/EvwITEwRgnV0Zx0fAHYBh0khBD4sBAmAgDiwQNg4qwmSBDAYf7Fi+n97al9UlObnvO836f3tO355b2GsAYZrCBPRzGdSPmx8J3YtXwDDsB7TR2wl/rNmAYK13C07ES9W11E9s9BjTHdnBKVf8PAcWgehpwCssF0w/5FzqLgw7AA7zDQ/wqzC8H90jjSeFMYW0Yr8PzALfjOh7z1wve2YTzpLlQw2ay+KZ1N7vS24SziVqGexhKzB07pEJXk/dDwTetdZ9HewwZLWFNw2oyudZjQFNrCW8109pqS32GpPX1TOu586fPkLR+IEMjmbzYZ0ha34Atx/fwW58hXxPeFixo7Yg7PQbcKmEtZFgsMb/C4AkDBuUnQKpFuFZI3cZuvP6C+8g6wDP572O95C4Og49/W/YJl/G5YPqO9yV3dh4f8LMCfhjcI93Afix8xAX5SVx2YBY10yagEdxjmiwY7uISXuIFrlSEPG0TMllWcAbzYViXd0rzeXC6ImSiImA+eKU6h7mCeV/eCBMnCJkLzpHSztnFCJ7L//ZkOFv1iRLtRd1IcLpSHVP4jccVnkexPqXkmd7UX15b7tiz29ReAAAAAElFTkSuQmCC'
|
||||
},
|
||||
{
|
||||
prizeId: 5,
|
||||
prizeName: '1卷抽纸',
|
||||
prizeStock: 3,
|
||||
prizeWeight: 3000,
|
||||
prizeImage: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAABCElEQVRoge3YMa4BURSH8Y8o7UAp0WgkotBZwluAfhqlZSgUGr23ENUUCpppJnTswAIUSCaTiziZJ8d9/193zdzrfMltABF5plb+oLscDoAV0Pn8OC/lwDhL0k35QT3wstcIuM61Cj0IhXiNuAvOFwr5SgrxRiHeKMSbhnHfAVgU1i1gajhnBpwK6wnQtgxkDTlmSTq/L7rLYQ9byG+WpLvCOT8YQ6K5WgrxRiHeKMQbhXijEG8U4o1CvIkmxPrDquwMrI37KlFJSJake2BUxVlW0VytaEKsV6t5+8Ohak3rRmtIH9hav/QvRHO1FOKNQrwJheQfn+I9wflCIeNHLzuQc51PRP6rC1ZeIm1I8cC5AAAAAElFTkSuQmCC'
|
||||
},
|
||||
{
|
||||
prizeId: 6,
|
||||
prizeName: '0.2元现金',
|
||||
prizeStock: 8,
|
||||
prizeWeight: 120
|
||||
},
|
||||
{
|
||||
prizeId: 7,
|
||||
prizeName: '谢谢参与',
|
||||
prizeStock: 100,
|
||||
prizeWeight: 10000
|
||||
},
|
||||
{
|
||||
prizeId: 8,
|
||||
prizeName: '100金币',
|
||||
prizeStock: 100,
|
||||
prizeWeight: 3000
|
||||
}
|
||||
]
|
||||
})
|
||||
}, 200)
|
||||
})
|
||||
},
|
||||
// 抽奖开始之前
|
||||
async handleDrawBefore(callback) {
|
||||
|
||||
console.log('抽奖开始之前')
|
||||
let flag = false
|
||||
|
||||
// 还有免费数次
|
||||
if (this.freeNum > 0) {
|
||||
this.freeNum--
|
||||
flag = true
|
||||
} else {
|
||||
flag = false
|
||||
uni.showModal({
|
||||
title: '抽奖次数不足',
|
||||
icon:'none'
|
||||
})
|
||||
}
|
||||
|
||||
callback(flag)
|
||||
},
|
||||
// 本次抽奖开始
|
||||
handleDrawStart() {
|
||||
console.log('触发抽奖按钮')
|
||||
if (this.prizeing) return
|
||||
this.prizeing = true
|
||||
|
||||
this.tryLotteryDraw()
|
||||
},
|
||||
// 尝试发起抽奖
|
||||
tryLotteryDraw() {
|
||||
console.log('旋转开始,获取中奖下标......')
|
||||
// 判断是否由前端控制概率
|
||||
if (this.onFrontend) {
|
||||
this.localGetPrizeIndex()
|
||||
} else {
|
||||
this.remoteGetPrizeIndex()
|
||||
}
|
||||
},
|
||||
// 本地获取中奖下标
|
||||
localGetPrizeIndex() {
|
||||
console.warn('###当前处于前端控制中奖概率,安全起见,强烈建议由后端控制###')
|
||||
// 前端控制概率的情况下,需要拿到最接近随机权重且大于随机权重的值
|
||||
// 后端控制概率的情况下,通常会直接返回 prizeId
|
||||
if (!this.prizeWeightMax || !this.prizeWeightArr.length) {
|
||||
console.warn('###当前已开启前端控制中奖概率,但是奖品数据列表中的 prizeWeight 参数似乎配置不正确###')
|
||||
return
|
||||
}
|
||||
console.log('当前权重最大值为 =>', this.prizeWeightMax)
|
||||
|
||||
// 注意这里使用了 Math.ceil,如果某个权重的值为 0,则始终无法中奖
|
||||
let randomWeight = Math.ceil(Math.random() * this.prizeWeightMax)
|
||||
console.log('本次权重随机数 =>', randomWeight)
|
||||
|
||||
// 生成大于等于随机权重的数组
|
||||
let tempMaxArrs = []
|
||||
this.prizeList.forEach((item) => {
|
||||
if (item.prizeWeight >= randomWeight) {
|
||||
tempMaxArrs.push(item.prizeWeight)
|
||||
}
|
||||
})
|
||||
console.log('tempMaxArrs', tempMaxArrs)
|
||||
|
||||
// 如果大于随机权重的数组有值,先对这个数组排序然后取值
|
||||
// 反之新建一个临时的包含所有权重的已排序数组,然后取值
|
||||
let tempMaxArrsLen = tempMaxArrs.length
|
||||
if (tempMaxArrsLen) {
|
||||
tempMaxArrs.sort((a, b) => a - b)
|
||||
// 取值时,如果存在多个值,分两种情况
|
||||
if (tempMaxArrsLen > 1) {
|
||||
// 检查是否存在重复的值
|
||||
let sameCount = 0
|
||||
for (let i = 0; i < tempMaxArrs.length; i++) {
|
||||
if (tempMaxArrs[i] === tempMaxArrs[0]) {
|
||||
sameCount++
|
||||
}
|
||||
}
|
||||
|
||||
// 值不相等的情况下取最接近的值,也就是第1个值
|
||||
if (sameCount === 1) {
|
||||
this.prizeIndex = this.prizeWeightArr.indexOf(tempMaxArrs[0])
|
||||
} else {
|
||||
// 存在值相等时,随机取值,当然这里你可以自己决定是否随机取值
|
||||
let sameWeight = tempMaxArrs[0]
|
||||
let sameWeightArr = []
|
||||
let sameWeightItem = {}
|
||||
this.prizeWeightArr.forEach((item, index) => {
|
||||
if (item === sameWeight) {
|
||||
sameWeightArr.push({
|
||||
prizeWeight: item,
|
||||
index
|
||||
})
|
||||
}
|
||||
})
|
||||
console.log('sameWeightArr', sameWeightArr)
|
||||
sameWeightItem = sameWeightArr[Math.floor(Math.random() * sameWeightArr.length)]
|
||||
console.log('sameWeightItem', sameWeightItem)
|
||||
this.prizeIndex = sameWeightItem.index
|
||||
}
|
||||
} else {
|
||||
this.prizeIndex = this.prizeWeightArr.indexOf(tempMaxArrs[0])
|
||||
}
|
||||
}
|
||||
|
||||
console.log('本次抽中奖品 =>', this.prizeList[this.prizeIndex].prizeName)
|
||||
|
||||
// 如果奖品设有库存
|
||||
if (this.onStock) {
|
||||
console.log('本次奖品库存 =>', this.prizeList[this.prizeIndex].prizeStock)
|
||||
}
|
||||
},
|
||||
// 远程请求接口获取中奖下标
|
||||
// 大哥,这里只是模拟,别告诉我你不会对接自己的接口
|
||||
async remoteGetPrizeIndex() {
|
||||
console.warn('###当前处于模拟的请求接口,并返回了中奖信息###')
|
||||
const res = await this.$Request.getT('app/discSpinning/draw', {
|
||||
orderId: this.option.orderId
|
||||
})
|
||||
if (res.code == 0) {}
|
||||
return
|
||||
// 模拟请求接口获取中奖信息
|
||||
let stoTimer = setTimeout(() => {
|
||||
stoTimer = null
|
||||
|
||||
let list = [...this.prizeList]
|
||||
|
||||
// 这里随机产生的 prizeId 是模拟后端返回的 prizeId
|
||||
let prizeId = Math.floor(Math.random() * list.length + 1)
|
||||
|
||||
// 拿到后端返回的 prizeId 后,开始循环比对得出那个中奖的数据
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
let item = list[i]
|
||||
if (item.prizeId === prizeId) {
|
||||
// 中奖下标
|
||||
this.prizeIndex = i
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
console.log('本次抽中奖品 =>', this.prizeList[this.prizeIndex].prizeName)
|
||||
|
||||
// 如果奖品设有库存
|
||||
if (this.onStock) {
|
||||
console.log('本次奖品库存 =>', this.prizeList[this.prizeIndex].prizeStock)
|
||||
}
|
||||
}, 200)
|
||||
},
|
||||
// 本次抽奖结束
|
||||
handleDrawEnd() {
|
||||
console.log('旋转结束,执行拿到结果后到逻辑')
|
||||
|
||||
// 旋转结束后,开始处理拿到结果后的逻辑
|
||||
let prizeName = this.prizeList[this.prizeIndex].prizeName
|
||||
let tipContent = ''
|
||||
|
||||
if (prizeName === '谢谢参与') {
|
||||
tipContent = '很遗憾,没有中奖,请再接再厉!'
|
||||
} else {
|
||||
// 如果奖品设有库存
|
||||
if (this.onStock) {
|
||||
let prizeStock = this.prizeList[this.prizeIndex].prizeStock
|
||||
tipContent = prizeStock ? `恭喜您,获得 ${prizeName}` : `很抱歉,您来晚了,当前奖品 ${prizeName} 已无库存`
|
||||
} else {
|
||||
tipContent = `恭喜您,获得 ${prizeName} !`
|
||||
}
|
||||
}
|
||||
|
||||
uni.showModal({
|
||||
content: tipContent,
|
||||
showCancel: false,
|
||||
complete: () => {
|
||||
this.prizeing = false
|
||||
}
|
||||
})
|
||||
},
|
||||
// 抽奖转盘绘制完成
|
||||
handleDrawFinish(res) {
|
||||
console.log('抽奖转盘绘制完成', res)
|
||||
|
||||
if (res.ok) {
|
||||
// 计算结束绘制的时间
|
||||
if (console.timeEnd) {
|
||||
console.timeEnd('绘制转盘用时')
|
||||
}
|
||||
}
|
||||
|
||||
let stoTimer = setTimeout(() => {
|
||||
stoTimer = null
|
||||
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
mask: true,
|
||||
icon: 'none'
|
||||
})
|
||||
}, 50)
|
||||
}
|
||||
},
|
||||
onLoad(opt) {
|
||||
this.option=opt
|
||||
this.prizeList = []
|
||||
this.getPrizeList()
|
||||
},
|
||||
onUnload() {
|
||||
uni.hideLoading()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.btn-group {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 2;
|
||||
top: 200px;
|
||||
gap: 20rpx;
|
||||
padding: 0 32rpx;
|
||||
}
|
||||
|
||||
.almost-lottery {
|
||||
flex: 1;
|
||||
background-color: #FF893F;
|
||||
}
|
||||
|
||||
.almost-lottery__head {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 640rpx;
|
||||
background: url('~static/images/lottery/top-bg.png') no-repeat center center/cover;
|
||||
|
||||
.action {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex: 1;
|
||||
height: 88rpx;
|
||||
line-height: 88rpx;
|
||||
margin: 0 auto;
|
||||
color: #FFFFFF;
|
||||
font-size: 32rpx;
|
||||
background-color: rgba(255, 136, 61, 1);
|
||||
border-radius: 44rpx;
|
||||
}
|
||||
|
||||
.action-shadow {
|
||||
box-shadow: 0px 14rpx 0px 0px rgba(235, 112, 36, 1);
|
||||
}
|
||||
|
||||
.pack {
|
||||
width: 44rpx;
|
||||
height: 44rpx;
|
||||
margin-right: 10rpx;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center center;
|
||||
background-size: contain;
|
||||
background-image: url("~static/red-pack.png");
|
||||
}
|
||||
|
||||
.gift {
|
||||
width: 44rpx;
|
||||
height: 44rpx;
|
||||
margin-right: 10rpx;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center center;
|
||||
background-size: contain;
|
||||
background-image: url("~static/gift.png");
|
||||
}
|
||||
|
||||
.gold {
|
||||
width: 44rpx;
|
||||
height: 44rpx;
|
||||
margin-right: 10rpx;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center center;
|
||||
background-size: contain;
|
||||
background-image: url("~static/images/lottery/gold.png");
|
||||
|
||||
@media (-webkit-min-device-pixel-ratio: 2),
|
||||
(min-device-pixel-ratio: 2) {
|
||||
background-image: url("~static/images/lottery/gold@2x.png");
|
||||
}
|
||||
|
||||
@media (-webkit-min-device-pixel-ratio: 3),
|
||||
(min-device-pixel-ratio: 3) {
|
||||
background-image: url("~static/images/lottery/gold@3x.png");
|
||||
}
|
||||
}
|
||||
|
||||
.num {
|
||||
color: #F9FC31;
|
||||
}
|
||||
|
||||
.tip {
|
||||
position: relative;
|
||||
top: 428rpx;
|
||||
color: #FFFFFF;
|
||||
font-size: 24rpx;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.almost-lottery__wheel {
|
||||
text-align: center;
|
||||
|
||||
.almost-lottery__count {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
padding: 40rpx 0;
|
||||
}
|
||||
|
||||
.text {
|
||||
color: #FFFFFF;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.almost-lottery__rule {
|
||||
padding: 0 28rpx;
|
||||
color: #FFF8CB;
|
||||
|
||||
.rule-head {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
margin: 40rpx 0;
|
||||
|
||||
.line {
|
||||
flex: 1;
|
||||
height: 1px;
|
||||
background-color: #FFF3A5;
|
||||
}
|
||||
|
||||
.title {
|
||||
width: 280rpx;
|
||||
color: #F63857;
|
||||
line-height: 70rpx;
|
||||
text-align: center;
|
||||
margin: 0 20rpx;
|
||||
border-radius: 8rpx;
|
||||
background-image: linear-gradient(0deg, rgba(255, 242, 158, 1), rgba(255, 244, 168, 1));
|
||||
}
|
||||
}
|
||||
|
||||
.rule-body {
|
||||
color: #FFF8CB;
|
||||
font-size: 24rpx;
|
||||
padding: 10rpx 0 40rpx;
|
||||
|
||||
.item {
|
||||
display: flex;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.number {
|
||||
position: relative;
|
||||
top: 4rpx;
|
||||
width: 28rpx;
|
||||
height: 28rpx;
|
||||
line-height: 28rpx;
|
||||
text-align: center;
|
||||
color: #F63857;
|
||||
background: #FFF8CB;
|
||||
border-radius: 50%;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
.text {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.item-rule .text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.almost-lottery__action-dev {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 400rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 10rpx;
|
||||
text-align: center;
|
||||
background-color: red;
|
||||
margin: 0 auto 40rpx;
|
||||
|
||||
.text {
|
||||
color: #FFFFFF;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.almost-lottery__popup-wrap {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
.almost-lottery {
|
||||
background: transparent;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -155,12 +155,12 @@
|
||||
{{countPrice}}金币解锁单集视频
|
||||
</text>
|
||||
</view>
|
||||
<view class="pay-content-item" @click="goNav('/pages/me/vip/index')" v-if="isVips == '是'">
|
||||
<!-- <view class="pay-content-item" @click="goNav('/pages/me/vip/index')" v-if="isVips == '是'">
|
||||
<image class="pay-content-item-icon" src="../../static/images/me/rmIcon.png" mode=""></image>
|
||||
<text class="pay-content-items">
|
||||
开通会员
|
||||
</text>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
</view>
|
||||
</view>
|
||||
@@ -176,6 +176,8 @@
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
|
||||
|
||||
<!-- 支付弹窗 -->
|
||||
<uni-popup ref="popuppay" :safe-area="false">
|
||||
<view class="popuppay">
|
||||
@@ -291,6 +293,14 @@
|
||||
|
||||
</view>
|
||||
</uni-popup>
|
||||
|
||||
<!-- 抽奖弹窗 -->
|
||||
<!-- <uni-popup ref="refPopupZhuanPan" :safe-area="true" background-color="#ffffff">
|
||||
<view case="">
|
||||
111
|
||||
<l-dialer :prizeList="prizeList" @click="onClick" @done="onDone" ref="dialer" />
|
||||
</view>
|
||||
</uni-popup> -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -301,6 +311,50 @@
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
// 奖品列表,
|
||||
prizeList: [{
|
||||
id: 'coupon88',
|
||||
name: '8.8折',
|
||||
img: 'https://img11.360buyimg.com/pop/jfs/t1/175718/35/12595/5477/60b660c6Eb850717b/a1cfe750dcdb5b78.png',
|
||||
},
|
||||
{
|
||||
id: 'coupon900',
|
||||
Color: 'rgb(251, 219, 216)',
|
||||
name: '900',
|
||||
img: 'https://img11.360buyimg.com/pop/jfs/t1/190845/9/6092/4489/60b65fe8Ebb8f8284/955da889f6d1c13e.png',
|
||||
},
|
||||
{
|
||||
id: 'coupon1',
|
||||
name: '1元',
|
||||
img: 'https://img11.360buyimg.com/pop/jfs/t1/189927/14/6092/4174/60b66173E23c472ea/44af15a151defca1.png',
|
||||
},
|
||||
{
|
||||
id: 'apple',
|
||||
Color: 'rgba(246, 142, 46, 0.5)',
|
||||
name: '苹果手机',
|
||||
img: 'https://img11.360buyimg.com/pop/jfs/t1/177670/26/4591/2514/60a25874Ee0e5332a/99c7bdfede732ae4.png'
|
||||
},
|
||||
{
|
||||
id: 'coupon210',
|
||||
name: '210元',
|
||||
img: 'https://img11.360buyimg.com/pop/jfs/t1/124578/12/20170/4429/60b635d8E7089ebb0/7a47d76a2a260cc0.png'
|
||||
},
|
||||
{
|
||||
id: 'jd100',
|
||||
name: '100京豆',
|
||||
img: 'https://img11.360buyimg.com/pop/jfs/t1/162790/37/15087/28046/6062a49aE8f2c10f2/5591ff0ff38a45e2.png',
|
||||
},
|
||||
{
|
||||
id: 'coupon400',
|
||||
name: '400元',
|
||||
img: 'https://img11.360buyimg.com/pop/jfs/t1/177090/2/7001/4535/60b6607aEe9c1db2a/76c67675f547db3f.png'
|
||||
},
|
||||
{
|
||||
id: 'thanks',
|
||||
name: '谢谢参与',
|
||||
img: 'https://storage.jd.com/cdn-upload/dialTemplateHeart.png',
|
||||
}
|
||||
],
|
||||
showMoney: true,
|
||||
nowBs: 1, //当前倍速
|
||||
subList: [{
|
||||
@@ -481,6 +535,17 @@
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onDone(index) {
|
||||
const prize = this.prizeList[index]
|
||||
uni.showModal({
|
||||
title: prize.id == 'thanks' ? '很遗憾' : '恭喜您',
|
||||
content: (prize.id !== 'thanks' ? `获得` : '') + prize.name
|
||||
})
|
||||
},
|
||||
onClick() {
|
||||
// 奖品的索引
|
||||
this.$refs.dialer.run(5)
|
||||
},
|
||||
appear(e, index) {
|
||||
this.current = index
|
||||
this.showControls = true
|
||||
@@ -768,6 +833,7 @@
|
||||
//打开支付弹窗
|
||||
openPopusPay() {
|
||||
this.$refs.popuppay.open('bottom')
|
||||
// this.$refs.refPopupZhuanPan.open('bottom')
|
||||
},
|
||||
// 获取收藏状态
|
||||
getMyLoveStatus() {
|
||||
|
||||
@@ -211,15 +211,19 @@
|
||||
<!-- #endif -->
|
||||
</view>
|
||||
</view>
|
||||
<view class="list-item" v-if="isVips == '是' && isWxIosPay == true">
|
||||
<view class="list-item-box flex align-center justify-center" @click="goNav('/pages/me/vip/index')">
|
||||
<image src="../../static/images/me/rmIcon.png" mode=""></image>
|
||||
开通会员
|
||||
<!-- #ifdef MP-TOUTIAO || MP-WEIXIN-->
|
||||
(会员期内免费观看)
|
||||
<!-- #endif -->
|
||||
<template v-if="false">
|
||||
<view class="list-item" v-if="isVips == '是' && isWxIosPay == true">
|
||||
<view class="list-item-box flex align-center justify-center" @click="goNav('/pages/me/vip/index')">
|
||||
<image src="../../static/images/me/rmIcon.png" mode=""></image>
|
||||
开通会员
|
||||
<!-- #ifdef MP-TOUTIAO || MP-WEIXIN-->
|
||||
(会员期内免费观看)
|
||||
<!-- #endif -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<view class="list-item" v-if="isGuanggao == '是'&& adUnitId && advertising">
|
||||
<view class="list-item-box" @click="openVideoAd()">
|
||||
@@ -249,6 +253,15 @@
|
||||
|
||||
</view>
|
||||
</u-popup>
|
||||
|
||||
<!-- <u-popup :closeable="true" :custom-style="customStyle" :safe-area-inset-bottom="false" close-icon="close"
|
||||
close-icon-size="30" close-icon-color="#333333" :mask-custom-style="maskCustomStyle" v-model="showPay"
|
||||
border-radius="24" mode="bottom">
|
||||
<view class="list u-flex u-row-center u-p-t-60">
|
||||
<l-dialer :prizeList="prizeList" @click="onClick" @done="onDone" ref="dialer" />
|
||||
</view>
|
||||
</u-popup> -->
|
||||
|
||||
<!-- 充值购买弹窗 -->
|
||||
<payPopus v-if="showMoney" :payPrice="payPrice" :show="showMoney" @closeMoney="closeMoney"
|
||||
@paySuccess="paySuccess" />
|
||||
@@ -305,6 +318,50 @@
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
//奖品列表
|
||||
prizeList: [{
|
||||
id: 'coupon88',
|
||||
name: '8.8折',
|
||||
img: 'https://img11.360buyimg.com/pop/jfs/t1/175718/35/12595/5477/60b660c6Eb850717b/a1cfe750dcdb5b78.png',
|
||||
},
|
||||
{
|
||||
id: 'coupon900',
|
||||
Color: 'rgb(251, 219, 216)',
|
||||
name: '900',
|
||||
img: 'https://img11.360buyimg.com/pop/jfs/t1/190845/9/6092/4489/60b65fe8Ebb8f8284/955da889f6d1c13e.png',
|
||||
},
|
||||
{
|
||||
id: 'coupon1',
|
||||
name: '1元',
|
||||
img: 'https://img11.360buyimg.com/pop/jfs/t1/189927/14/6092/4174/60b66173E23c472ea/44af15a151defca1.png',
|
||||
},
|
||||
{
|
||||
id: 'apple',
|
||||
Color: 'rgba(246, 142, 46, 0.5)',
|
||||
name: '苹果手机',
|
||||
img: 'https://img11.360buyimg.com/pop/jfs/t1/177670/26/4591/2514/60a25874Ee0e5332a/99c7bdfede732ae4.png'
|
||||
},
|
||||
{
|
||||
id: 'coupon210',
|
||||
name: '210元',
|
||||
img: 'https://img11.360buyimg.com/pop/jfs/t1/124578/12/20170/4429/60b635d8E7089ebb0/7a47d76a2a260cc0.png'
|
||||
},
|
||||
{
|
||||
id: 'jd100',
|
||||
name: '100京豆',
|
||||
img: 'https://img11.360buyimg.com/pop/jfs/t1/162790/37/15087/28046/6062a49aE8f2c10f2/5591ff0ff38a45e2.png',
|
||||
},
|
||||
{
|
||||
id: 'coupon400',
|
||||
name: '400元',
|
||||
img: 'https://img11.360buyimg.com/pop/jfs/t1/177090/2/7001/4535/60b6607aEe9c1db2a/76c67675f547db3f.png'
|
||||
},
|
||||
{
|
||||
id: 'thanks',
|
||||
name: '谢谢参与',
|
||||
img: 'https://storage.jd.com/cdn-upload/dialTemplateHeart.png',
|
||||
}
|
||||
],
|
||||
checked: false,
|
||||
payPrice: 0, //需要支付的价格
|
||||
showMoney: false, //是否显示充值弹窗
|
||||
@@ -676,6 +733,17 @@
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
onDone(index) {
|
||||
const prize = this.prizeList[index]
|
||||
uni.showModal({
|
||||
title: prize.id == 'thanks' ? '很遗憾' : '恭喜您',
|
||||
content: (prize.id !== 'thanks' ? `获得` : '') + prize.name
|
||||
})
|
||||
},
|
||||
onClick() {
|
||||
// 奖品的索引
|
||||
this.$refs.dialer.run(5)
|
||||
},
|
||||
goWallet(url) {
|
||||
uni.navigateTo({
|
||||
url: url
|
||||
|
||||
54
me/gift/duihuan.vue
Normal file
@@ -0,0 +1,54 @@
|
||||
<template>
|
||||
<view class="min-page bg-gray u-font-28">
|
||||
<view class="block bg-fff border-r-18 default-box-padding">
|
||||
<view>
|
||||
<view>兑换账号</view>
|
||||
<view class="border u-m-t-24 u-p-l-24">
|
||||
<u-input type="text" placeholder="请输入兑换账号"></u-input>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-48">
|
||||
<view>兑换事项</view>
|
||||
<view class="u-m-t-16 color-999">
|
||||
请认真核实兑换账号,一但兑换成功后,不予退换。
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-flex u-row-center">
|
||||
<view class="btn-circle duihuan">确认兑换</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.border {
|
||||
border: 1px solid #999999;
|
||||
border-radius: 12rpx 12rpx 12rpx 12rpx;
|
||||
}
|
||||
.duihuan{
|
||||
background: #ED838A;
|
||||
width: 556rpx;
|
||||
padding: 18rpx 0;
|
||||
text-align: center;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
margin-top: 84rpx;
|
||||
}
|
||||
.min-page {
|
||||
padding: 32rpx 20rpx;
|
||||
}
|
||||
</style>
|
||||
101
me/gift/gift.vue
Normal file
@@ -0,0 +1,101 @@
|
||||
<template>
|
||||
<view class="min-page bg-gray u-font-28">
|
||||
<u-navbar :background="background" back-icon-color="#fff" immersive :border-bottom="false"></u-navbar>
|
||||
<view class="gift-bg">
|
||||
</view>
|
||||
<view class="list">
|
||||
<view class="item" v-for="(item,index) in 10" :key="index">
|
||||
<view class="color-666 u-font-24">中奖时间 2024-09-11 10:20:11</view>
|
||||
<view class="u-m-t-24 u-flex u-row-between">
|
||||
<view class="u-flex-1 u-flex u-col-top">
|
||||
<u-image width="128rpx" height="128rpx" src="/static/red-pack.png"></u-image>
|
||||
<view class="u-m-l-16">
|
||||
<view>大额红包</view>
|
||||
<view class="color-999 u-font-24 u-m-t-16">×1</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="">
|
||||
<view class="btn-circle duihuan" @click="toDuiHuan">立即兑换</view>
|
||||
<!-- <view class="btn-circle duihuan finish">已完成</view> -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-p-30">
|
||||
<u-loadmore :font-size="24" color="#999" :status="status" />
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
background: {
|
||||
backgroundColor: 'transparent'
|
||||
},
|
||||
status: 'nomore'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
toDuiHuan(){
|
||||
uni.navigateTo({
|
||||
url:'/me/gift/duihuan'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.duihuan {
|
||||
background: linear-gradient(87deg, #ED8087 0%, #ECA2AA 100%);
|
||||
font-size: 24rpx;
|
||||
color: #fff;
|
||||
padding: 8rpx 16rpx;
|
||||
text-align: center;
|
||||
|
||||
&.finish {
|
||||
background: #E5E5E5;
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.gift-bg {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 524rpx;
|
||||
background: url('~static/images/gift-bg.png') no-repeat center center/cover;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center center;
|
||||
background-size: cover;
|
||||
background-image: url("~static/images/gift-bg.png");
|
||||
|
||||
@media (-webkit-min-device-pixel-ratio: 2),
|
||||
(min-device-pixel-ratio: 2) {
|
||||
background-image: url("~static/images/gift-bg@2x.png");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.min-page {
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.list {
|
||||
margin: 0 20rpx;
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
margin-top: -148rpx;
|
||||
border-radius: 18rpx 18rpx 18rpx 18rpx;
|
||||
overflow: hidden;
|
||||
background-color: #fff;
|
||||
padding: 0 24rpx;
|
||||
|
||||
.item {
|
||||
padding: 32rpx 0;
|
||||
border-bottom: 1rpx solid #E5E5E5;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
22
pages.json
@@ -556,6 +556,28 @@
|
||||
"enablePullDownRefresh": false,
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "choujiang/choujiang",
|
||||
"style" :
|
||||
{
|
||||
"navigationBarTitleText" : "抽奖"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "gift/gift",
|
||||
"style" :
|
||||
{
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText" : "奖品列表"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "gift/duihuan",
|
||||
"style" :
|
||||
{
|
||||
"navigationBarTitleText" : "兑换礼品"
|
||||
}
|
||||
}
|
||||
]
|
||||
}],
|
||||
|
||||
1290
pages/login/login - 副本.vue
Normal file
@@ -1,83 +1,41 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<!-- 小程序状态下登录 -->
|
||||
<!-- #ifdef MP-WEIXIN || MP-TOUTIAO || MP-KUAISHOU -->
|
||||
<view class="mp_wxBox">
|
||||
<view>
|
||||
<view class="headers">
|
||||
<image src="../../static/images/logo.png" style="border-radius: 50%;"></image>
|
||||
|
||||
<view class="wrapper">
|
||||
<view class="input-content">
|
||||
<view class="cu-form-group"
|
||||
style="border: 2upx solid whitesmoke;margin-bottom: 20px;border-radius: 30px">
|
||||
<view class="title">手机号</view>
|
||||
<input type="number" :value="mobile" placeholder="请输入手机号" maxlength="11" data-key="mobile"
|
||||
@input="inputChange" />
|
||||
</view>
|
||||
<view class="content">
|
||||
<view>申请获取以下权限</view>
|
||||
<text>获得你的公开信息(昵称,头像、地区等)</text>
|
||||
<view class="cu-form-group" style="border: 2upx solid whitesmoke;border-radius: 30px">
|
||||
<view class="title">密
|
||||
<text style="margin-left: 30rpx;">码</text>
|
||||
</view>
|
||||
<input type="password" placeholder="请输入密码" maxlength="20" :value="code" data-key="code"
|
||||
@input="inputChange" @confirm="toLogin" />
|
||||
<text class="send-msg" @click="forget">忘记密码</text>
|
||||
</view>
|
||||
<button v-show="weixinPhone" style="background: #ff7581;color: #FFFFFF;" class="bottom"
|
||||
open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
|
||||
授权手机号
|
||||
</button>
|
||||
<button v-show="!weixinPhone" style="background: #ff7581;color: #FFFFFF;" class='bottom'
|
||||
bindtap="getUserProfile" @tap="wxGetUserInfo">
|
||||
授权登录
|
||||
</button>
|
||||
</view>
|
||||
<button class="confirm-btn" @click="toLogin">登录</button>
|
||||
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- #ifdef H5 -->
|
||||
<view style="text-align: center;">
|
||||
<image style="width: 120upx;height: 120upx;margin-top: 140upx;border-radius:20upx"
|
||||
src="../../static/images/logo.png"></image>
|
||||
|
||||
<button class='confirm-btn' v-if="!isopen" @click="register">手机号登录</button>
|
||||
<button class='confirm-btn' v-if="isopen" @click="bingwx">微信一键登录</button>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
<!-- #ifdef APP -->
|
||||
<view style="text-align: center;">
|
||||
<image style="width: 120upx;height: 120upx;margin-top: 140upx;border-radius:20upx"
|
||||
src="../../static/images/logo.png"></image>
|
||||
|
||||
<button class='confirm-btn' v-if="!isopen" @click="register">手机号登录</button>
|
||||
<button class='confirm-btn' v-if="isopen" @click="bingwx">微信一键登录</button>
|
||||
</view>
|
||||
<view v-if="phoneLogin || weixinLogin || CheckiosLogin"
|
||||
style="display: flex;align-items: center;width: 100%;justify-content: center;margin-top: 250upx;">
|
||||
<view style="width: 100rpx;height: 1rpx;background: #d1d1d1;"></view>
|
||||
<view style="color: #333333;margin: 0 20rpx;">其他方式登录</view>
|
||||
<view style="width: 100rpx;height: 1rpx;background: #d1d1d1;"></view>
|
||||
</view>
|
||||
<view style="display: flex;margin-top: 80upx;width: 750rpx;justify-content: center;">
|
||||
<view style="flex: 1;text-align: center;" v-if="phoneLogin">
|
||||
<image src="/static/images/me/icon_phone.png" @tap="login_phone" style="width: 90upx;height: 90upx;">
|
||||
</image>
|
||||
<view style="margin-top: 32px;text-align: center">
|
||||
<view>
|
||||
没有账号?
|
||||
<text style="color: #ff7581" @click="register()">立即注册</text>
|
||||
</view>
|
||||
</view>
|
||||
<view style="flex: 1;text-align: center;" v-if="weixinLogin">
|
||||
<image src="/static/images/index/weixin.png" @tap="appweixinLo" style="width: 90upx;height: 90upx;">
|
||||
</image>
|
||||
</view>
|
||||
<view style="flex: 1;text-align: center;" v-if="CheckiosLogin">
|
||||
<image src="/static/images/me/appleid_button.png" @tap="ioslogin" style="width: 90upx;height: 90upx;">
|
||||
</image>
|
||||
</view>
|
||||
<!-- <view style="flex: 1;text-align: center;" @tap="ioslogin" v-if="CheckiosLogin">
|
||||
<image src="../../static/pw/loginphone.png" style="width: 80upx;height: 80upx;"></image>
|
||||
</view> -->
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
|
||||
|
||||
<view class="footer" @click.stop="isCheck">
|
||||
<view style="display: flex;align-items: center;justify-content: center;">
|
||||
<u-checkbox-group>
|
||||
<u-checkbox active-color="#ff7581" v-model="checked" label-size='24upx' shape="circle"
|
||||
@change="radioChange"></u-checkbox>
|
||||
</u-checkbox-group>
|
||||
<view>同意</view>
|
||||
<!-- 协议地址 -->
|
||||
<text @click.stop="goTo('/me/setting/mimi')">《隐私政策》</text>和<text
|
||||
@click.stop="goTo('/me/setting/xieyi')">《用户协议》</text>
|
||||
</view>
|
||||
<view class="footer">
|
||||
<u-checkbox-group>
|
||||
<u-checkbox v-model="checked" label-size='24upx' shape="circle" @change="radioChange"></u-checkbox>
|
||||
</u-checkbox-group>
|
||||
<view>同意</view>
|
||||
<!-- 协议地址 -->
|
||||
<navigator url="/me/setting/mimi" open-type="navigate">《隐私政策》</navigator>
|
||||
和
|
||||
<navigator url="/me/setting/xieyi" open-type="navigate">《用户服务协议》</navigator>
|
||||
</view>
|
||||
<u-toast ref="uToast" />
|
||||
</view>
|
||||
@@ -97,465 +55,16 @@
|
||||
phone: '',
|
||||
sendTime: '获取验证码',
|
||||
count: 60,
|
||||
checked: false,
|
||||
isopen: false,
|
||||
qdCodeion: '',
|
||||
phoneLogin: false,
|
||||
CheckiosLogin: false,
|
||||
weixinLogin: false
|
||||
checked: false
|
||||
};
|
||||
},
|
||||
onLoad() {
|
||||
// this.$u.get('/app/common/type/108').then(res => { //// 是否开启公众号自动登陆 108
|
||||
// if (res.code == 0 && res.data) {
|
||||
// if (res.data.value == '是') {
|
||||
// // #ifdef H5
|
||||
// let ua = navigator.userAgent.toLowerCase();
|
||||
// if (ua.indexOf('micromessenger') !== -1) {
|
||||
// this.isopen = true;
|
||||
// } else {
|
||||
// this.isopen = false;
|
||||
// }
|
||||
// // #endif
|
||||
// } else {
|
||||
// this.isopen = false;
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// // #ifdef H5
|
||||
// this.selbindwx();
|
||||
// // #endif
|
||||
// #ifdef APP-PLUS
|
||||
let checkWxLogin = this.$queue.getData('checkWxLogin');
|
||||
if (checkWxLogin != '否') {
|
||||
this.weixinLogin = true;
|
||||
} else {
|
||||
this.weixinLogin = false;
|
||||
}
|
||||
let checkPhoneLogin = this.$queue.getData('checkPhoneLogin');
|
||||
if (checkPhoneLogin != '否') {
|
||||
this.phoneLogin = true;
|
||||
} else {
|
||||
this.phoneLogin = false;
|
||||
}
|
||||
switch (uni.getSystemInfoSync().platform) {
|
||||
case 'android':
|
||||
break;
|
||||
case 'ios':
|
||||
let checkIosLogins = this.$queue.getData('checkIosLogin');
|
||||
if (checkIosLogins != '否') {
|
||||
this.CheckiosLogin = true;
|
||||
} else {
|
||||
this.CheckiosLogin = false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// #endif
|
||||
//拿一下携带的渠道码
|
||||
if (uni.getStorageSync('qdCodeion')) {
|
||||
this.qdCodeion = uni.getStorageSync('qdCodeion')
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
appweixinLo() {
|
||||
if (!this.checked) {
|
||||
uni.showToast({
|
||||
title: '请同意隐私政策和用户服务协议',
|
||||
icon: 'none'
|
||||
})
|
||||
return;
|
||||
}
|
||||
let that = this;
|
||||
uni.login({
|
||||
provider: 'weixin',
|
||||
success: function(loginRes) {
|
||||
that.$queue.showLoading('正在登录中...');
|
||||
console.error(loginRes.authResult.openid);
|
||||
that.$queue.setData('weixinToken', loginRes.authResult.access_token);
|
||||
that.$queue.setData('unionid', loginRes.authResult.unionid);
|
||||
that.$queue.setData('weixinOpenid', loginRes.authResult.openid);
|
||||
that.$Request.postT('/app/Login/wxAppLogin', {
|
||||
token: loginRes.authResult.access_token,
|
||||
wxOpenId: loginRes.authResult.openid
|
||||
})
|
||||
.then(res => {
|
||||
console.log(JSON.stringify(res))
|
||||
if (res.code === 0) {
|
||||
that.$queue.setData('token', res.token);
|
||||
that.$queue.setData('userId', res.user.userId);
|
||||
uni.switchTab({
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
} else {
|
||||
uni.hideLoading();
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '需要绑定手机和完善资料,是否继续',
|
||||
confirmText: '继续注册',
|
||||
success: function(res) {
|
||||
if (res.confirm) {
|
||||
console.log('用户点击确定');
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/wxmobile'
|
||||
});
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
},
|
||||
login_phone() {
|
||||
if (!this.checked) {
|
||||
uni.showToast({
|
||||
title: '请同意隐私政策和用户服务协议',
|
||||
icon: 'none'
|
||||
})
|
||||
return;
|
||||
}
|
||||
let that = this;
|
||||
uni.getProvider({ //获取可用的服务提供商
|
||||
service: 'oauth',
|
||||
success: function(res) {
|
||||
console.log(res.provider) // ['weixin', qq', 'univerify']
|
||||
}
|
||||
});
|
||||
|
||||
uni.preLogin({ //预登录
|
||||
provider: 'univerify', //用手机号登录
|
||||
success() {
|
||||
console.log('预登录成功')
|
||||
uni.login({ //正式登录,弹出授权窗
|
||||
provider: 'univerify',
|
||||
univerifyStyle: { // 自定义登录框样式
|
||||
"fullScreen": false, // 是否全屏显示,true表示全屏模式,false表示非全屏模式,默认值为false。
|
||||
"backgroundColor": "#FFFFFF", // 授权页面背景颜色,默认值:#ffffff
|
||||
"icon": {
|
||||
"path": "static/logo.png" // 自定义显示在授权框中的logo,仅支持本地图片 默认显示App logo
|
||||
},
|
||||
"phoneNum": {
|
||||
"color": "#000000", // 手机号文字颜色 默认值:#000000
|
||||
},
|
||||
"authButton": {
|
||||
"normalColor": "#ff7581", // 授权按钮正常状态背景颜色 默认值:#3479f5
|
||||
"highlightColor": "#ff7581", // 授权按钮按下状态背景颜色 默认值:#2861c5(仅ios支持)
|
||||
"disabledColor": "#ff7581", // 授权按钮不可点击时背景颜色 默认值:#73aaf5(仅ios支持)
|
||||
"textColor": "#ffffff", // 授权按钮文字颜色 默认值:#ffffff
|
||||
"title": "本机号码一键登录" // 授权按钮文案 默认值:“本机号码一键登录”
|
||||
}
|
||||
},
|
||||
success(res) { // 正式登录成功
|
||||
console.log(res
|
||||
.authResult); // {openid:'登录授权唯一标识',access_token:'接口返回的 token'}
|
||||
|
||||
// 在得到access_token后,通过callfunction调用云函数
|
||||
uniCloud.callFunction({
|
||||
name: 'login', // 云函数名称
|
||||
data: { //传给云函数的参数
|
||||
'access_token': res.authResult
|
||||
.access_token, // 客户端一键登录接口返回的access_token
|
||||
'openid': res.authResult.openid // 客户端一键登录接口返回的openid
|
||||
},
|
||||
success(callRes) {
|
||||
console.log('调用云函数成功' + JSON.stringify(callRes))
|
||||
console.log("手机号:" + callRes.result.phoneNumber)
|
||||
that.savePhoneByUser(callRes.result.phoneNumber);
|
||||
},
|
||||
fail(callErr) {
|
||||
console.log('调用云函数出错' + callErr)
|
||||
},
|
||||
complete() {
|
||||
uni.closeAuthView() //关闭授权登录界面
|
||||
}
|
||||
})
|
||||
},
|
||||
fail(err) { // 正式登录失败
|
||||
console.log(err.errCode)
|
||||
console.log(err.errMsg)
|
||||
uni.closeAuthView() //关闭授权登录界面
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
fail(err) { //预登录失败
|
||||
console.log(err)
|
||||
console.log('错误码:' + err.errCode)
|
||||
console.log(err.errMsg)
|
||||
}
|
||||
})
|
||||
},
|
||||
savePhoneByUser(phone) {
|
||||
this.$queue.showLoading('登录中...')
|
||||
let that = this;
|
||||
that.$Request
|
||||
.postT('/app/Login/phoneLogin', {
|
||||
phone: phone
|
||||
})
|
||||
.then(ress => {
|
||||
console.log(JSON.stringify(ress))
|
||||
if (ress.code === 0) {
|
||||
that.$queue.setData('token', ress.token);
|
||||
that.$queue.setData('userId', ress.user.userId);
|
||||
console.log(ress.user.userId)
|
||||
console.log(ress.token)
|
||||
uni.switchTab({
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
} else {
|
||||
uni.hideLoading();
|
||||
uni.navigateTo({
|
||||
url: './phonebind?phone=' + phone
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
//app苹果登录
|
||||
ioslogin() {
|
||||
if (!this.checked) {
|
||||
uni.showToast({
|
||||
title: '请同意隐私政策和用户服务协议',
|
||||
icon: 'none'
|
||||
})
|
||||
return;
|
||||
}
|
||||
console.log("ioslogin")
|
||||
let that = this;
|
||||
uni.login({
|
||||
provider: 'apple',
|
||||
success: function(loginRes) {
|
||||
let iosopenid = loginRes.authResult.openid
|
||||
// 获取用户信息
|
||||
uni.getUserInfo({
|
||||
provider: 'apple',
|
||||
success(ress) {
|
||||
that.$queue.showLoading('登录中...');
|
||||
let datas = {
|
||||
identityToken: JSON.stringify(ress)
|
||||
}
|
||||
//在这里获取到苹果手机的ID后可以继续你的操作,请求后台进行登录
|
||||
that.$Request.postT('/app/Login/appleLogin', datas).then(re => {
|
||||
if (re.code == 0) {
|
||||
that.$queue.setData('appleId', re.data)
|
||||
that.$Request.getT(
|
||||
'/app/Login/insertAppleUser?appleId=' + re.data
|
||||
).then(res => {
|
||||
console.log(JSON.stringify(res))
|
||||
if (res.code == 0) {
|
||||
that.$queue.setData('token', res
|
||||
.token);
|
||||
that.$queue.setData('userId', res.user
|
||||
.userId);
|
||||
uni.switchTab({
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
} else {
|
||||
uni.hideLoading();
|
||||
if (res.code == 201) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '需要绑定手机和完善资料,是否继续',
|
||||
confirmText: '继续注册',
|
||||
success: function(
|
||||
res) {
|
||||
if (res
|
||||
.confirm) {
|
||||
console
|
||||
.log(
|
||||
'用户点击确定'
|
||||
);
|
||||
uni.navigateTo({
|
||||
url: './iosmobile'
|
||||
});
|
||||
} else if (res
|
||||
.cancel) {
|
||||
console
|
||||
.log(
|
||||
'用户点击取消'
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
} else if (res.code == 500) {
|
||||
that.$queue.showToast(res.msg);
|
||||
} else {
|
||||
that.$queue.showToast(res.msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
uni.hideLoading();
|
||||
that.$queue.showToast(re.msg)
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
fail: function(err) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: err,
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
goTo(url) {
|
||||
uni.navigateTo({
|
||||
url
|
||||
});
|
||||
},
|
||||
isCheck() {
|
||||
this.checked = !this.checked
|
||||
},
|
||||
selbindwx() {
|
||||
let ua = navigator.userAgent.toLowerCase();
|
||||
if (ua.indexOf('micromessenger') !== -1) {
|
||||
let openid = uni.getStorageSync('openid');
|
||||
let userId = uni.getStorageSync('userId');
|
||||
let that = this;
|
||||
if (!openid) {
|
||||
if (window.location.href.indexOf('?code=') !== -1 || window.location.href.indexOf('&code=') !==
|
||||
-1) {
|
||||
let code;
|
||||
if (window.location.href.indexOf('?code=') !== -1) {
|
||||
code = window.location.href.split('?code=')[1].split('&')[0];
|
||||
} else {
|
||||
code = window.location.href.split('&code=')[1].split('&')[0];
|
||||
}
|
||||
this.$Request.get('/app/Login/getOpenId?code=' + code).then(ret => {
|
||||
uni.setStorageSync('openid', ret.data)
|
||||
|
||||
this.$Request.get('/app/Login/openid/login?openId=' + ret.data).then(res => {
|
||||
if (res.code == 0) {
|
||||
this.$queue.setData("phone", res.user.phone);
|
||||
this.$queue.setData("userId", res.user.userId);
|
||||
this.$queue.setData("token", res.token);
|
||||
uni.setStorageSync('sex', res.user.sex)
|
||||
uni.setStorageSync('openId', res.user.openId)
|
||||
this.$queue.setData("userName", res.user.userName);
|
||||
this.$queue.setData("avatar", res.user.avatar);
|
||||
this.$queue.setData("invitationCode", res.user.invitationCode);
|
||||
this.$queue.setData("inviterCode", res.user.inviterCode);
|
||||
uni.switchTab({
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/bind'
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
// 微信公众号登录
|
||||
bingwx() {
|
||||
if (this.checked) {
|
||||
|
||||
let ua = navigator.userAgent.toLowerCase();
|
||||
if (ua.indexOf('micromessenger') !== -1) {
|
||||
let openid = uni.getStorageSync('openid');
|
||||
let userId = uni.getStorageSync('userId');
|
||||
let that = this;
|
||||
if (!openid) {
|
||||
if (window.location.href.indexOf('?code=') !== -1 || window.location.href.indexOf(
|
||||
'&code=') !==
|
||||
-1) {
|
||||
let code;
|
||||
if (window.location.href.indexOf('?code=') !== -1) {
|
||||
code = window.location.href.split('?code=')[1].split('&')[0];
|
||||
} else {
|
||||
code = window.location.href.split('&code=')[1].split('&')[0];
|
||||
}
|
||||
this.$Request.get('/app/Login/getOpenId?code=' + code).then(ret => {
|
||||
uni.setStorageSync('openid', ret.data)
|
||||
// uni.setStorageSync('openidheadimgurl', ret.data.headimgurl)
|
||||
// uni.setStorageSync('openidnickname', ret.data.nickname)
|
||||
|
||||
this.$Request.get('/app/Login/openid/login?openId=' + ret.data).then(
|
||||
res => {
|
||||
if (res.code == 0) {
|
||||
this.$queue.setData("phone", res.user.phone);
|
||||
this.$queue.setData("userId", res.user.userId);
|
||||
this.$queue.setData("token", res.token);
|
||||
uni.setStorageSync('sex', res.user.sex)
|
||||
uni.setStorageSync('openId', res.user.openId)
|
||||
this.$queue.setData("userName", res.user.userName);
|
||||
this.$queue.setData("avatar", res.user.avatar);
|
||||
this.$queue.setData("invitationCode", res.user
|
||||
.invitationCode);
|
||||
this.$queue.setData("inviterCode", res.user
|
||||
.inviterCode);
|
||||
uni.switchTab({
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/bind'
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
window.location.href =
|
||||
'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' +
|
||||
that.$queue.getWxAppid() +
|
||||
'&redirect_uri=' +
|
||||
window.location.href.split('#')[0] +
|
||||
'&response_type=code&scope=snsapi_userinfo#wechat_redirect';
|
||||
}
|
||||
} else {
|
||||
this.$Request.get('/app/Login/openid/login?openId=' + openid).then(res => {
|
||||
if (res.code == 0) {
|
||||
this.$queue.setData("phone", res.user.phone);
|
||||
this.$queue.setData("userId", res.user.userId);
|
||||
this.$queue.setData("token", res.token);
|
||||
this.$queue.setData("userName", res.user.userName);
|
||||
this.$queue.setData("avatar", res.user.avatar);
|
||||
this.$queue.setData("invitationCode", res.user.invitationCode);
|
||||
this.$queue.setData("inviterCode", res.user.inviterCode);
|
||||
uni.switchTab({
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/bind'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '请同意隐私政策和用户服务协议',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
// 注册
|
||||
register() {
|
||||
if (this.checked) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/loginPhone'
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '请同意隐私政策和用户服务协议',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/register'
|
||||
});
|
||||
},
|
||||
// 忘记密码
|
||||
forget() {
|
||||
@@ -574,36 +83,22 @@
|
||||
wxGetUserInfo(e) {
|
||||
let that = this;
|
||||
if (this.checked) {
|
||||
// wx.getUserProfile({
|
||||
// desc: '业务需要',
|
||||
// success: infoRes => {
|
||||
// console.log("infoRes.encryptedData__________:" + JSON.stringify(infoRes
|
||||
// .userInfo))
|
||||
// let nickName = infoRes.userInfo.nickName; //昵称
|
||||
// let avatarUrl = infoRes.userInfo.avatarUrl; //头像
|
||||
// let sex = infoRes.userInfo.gender; //性别
|
||||
// try {
|
||||
// that.login(nickName, avatarUrl, sex);
|
||||
// } catch (e) {}
|
||||
// },
|
||||
// fail(e) {
|
||||
// console.log(e, '222222222222222')
|
||||
// }
|
||||
// })
|
||||
let nickName = ''
|
||||
// #ifdef MP-WEIXIN
|
||||
nickName = '微信用户'
|
||||
// #endif
|
||||
// #ifdef MP-TOUTIAO
|
||||
nickName = '抖音用户'
|
||||
// #endif
|
||||
let avatarUrl = '/static/images/logo.png'
|
||||
let sex = 1
|
||||
that.login(nickName, avatarUrl, sex);
|
||||
wx.getUserProfile({
|
||||
desc: '业务需要',
|
||||
success: infoRes => {
|
||||
console.log("infoRes.encryptedData__________:" + JSON.stringify(infoRes.userInfo))
|
||||
let nickName = infoRes.userInfo.nickName; //昵称
|
||||
let avatarUrl = infoRes.userInfo.avatarUrl; //头像
|
||||
let sex = infoRes.userInfo.gender; //头像
|
||||
try {
|
||||
that.login(nickName, avatarUrl, sex);
|
||||
} catch (e) {}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.$refs.uToast.show({
|
||||
title: '请阅读并同意《隐私政策》和《用户服务协议》',
|
||||
duration: 1500
|
||||
uni.showToast({
|
||||
title: '请同意隐私政策和用户服务协议',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
@@ -614,75 +109,6 @@
|
||||
uni.login({
|
||||
provider: 'weixin',
|
||||
success: function(loginRes) {
|
||||
console.log(loginRes, 'code')
|
||||
// #ifdef MP-TOUTIAO
|
||||
|
||||
let data = {
|
||||
code: loginRes.code,
|
||||
anonymous_code: loginRes.anonymousCode
|
||||
}
|
||||
that.$Request.post('/app/Login/dyLogin', data).then(res => {
|
||||
if (res.code == 0) {
|
||||
let invitationCode = '';
|
||||
if (uni.getStorageSync('invitation')) {
|
||||
invitationCode = uni.getStorageSync('invitation')
|
||||
}
|
||||
//判断是否需要绑定手机号
|
||||
if (Number(res.data.flag) === 1) {
|
||||
that.weixinPhone = true;
|
||||
} else {
|
||||
uni.showLoading({
|
||||
title: '登录中...'
|
||||
})
|
||||
that.$Request.postJson('/app/Login/dyRegister', {
|
||||
userName: nickName, //抖音名称
|
||||
avatar: avatarUrl, //头像
|
||||
sex: sex, //性别
|
||||
// phone: '',
|
||||
inviterCode: invitationCode,
|
||||
dyOpenId: res.data.dyOpenId,
|
||||
qdCode: that.qdCodeion
|
||||
}).then(ress => {
|
||||
uni.hideLoading()
|
||||
if (ress.code == 0) {
|
||||
uni.setStorageSync('token', ress.token)
|
||||
uni.setStorageSync('userName', ress.user.userName)
|
||||
uni.setStorageSync('avatar', ress.user.avatar)
|
||||
uni.setStorageSync('phone', ress.user.phone)
|
||||
uni.setStorageSync('invitationCode', ress.user
|
||||
.invitationCode)
|
||||
if (ress.user.qdCode) {
|
||||
uni.setStorageSync('qdCode', ress.user.qdCode)
|
||||
}
|
||||
uni.setStorageSync('sex', ress.user.sex)
|
||||
uni.setStorageSync('userId', ress.user.userId)
|
||||
uni.setStorageSync('openId', ress.user.dyOpenId)
|
||||
that.$u.api.userVip({
|
||||
userId: uni.getStorageSync('userId')
|
||||
}).then(rest => {
|
||||
if (rest.code == 0 && rest.data && rest
|
||||
.data.isVip == 2) {
|
||||
uni.setStorageSync('isVIP', true)
|
||||
} else {
|
||||
uni.setStorageSync('isVIP', false)
|
||||
}
|
||||
})
|
||||
uni.navigateBack();
|
||||
} else {
|
||||
uni.showModal({
|
||||
showCancel: false,
|
||||
title: '登录失败',
|
||||
content: res.msg,
|
||||
});
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
// #ifdef MP-WEIXIN
|
||||
let data = {
|
||||
code: loginRes.code
|
||||
}
|
||||
@@ -702,8 +128,7 @@
|
||||
userName: nickName,
|
||||
avatar: avatarUrl,
|
||||
sex: sex, //性别
|
||||
inviterCode: invitationCode, //别人登录进来携带你的邀请码
|
||||
qdCode: that.qdCodeion
|
||||
inviterCode: invitationCode //别人登录进来携带你的邀请码
|
||||
};
|
||||
that.sendDataList = sendData;
|
||||
that.flag = res.data.flag;
|
||||
@@ -720,132 +145,18 @@
|
||||
});
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
// #ifdef MP-KUAISHOU
|
||||
let data = {
|
||||
code: loginRes.code,
|
||||
}
|
||||
that.$Request.post('/app/Login/ksLogin', data).then(res => {
|
||||
if (res.code == 0) {
|
||||
let invitationCode = '';
|
||||
if (uni.getStorageSync('invitation')) {
|
||||
invitationCode = uni.getStorageSync('invitation')
|
||||
}
|
||||
//判断是否需要绑定手机号
|
||||
if (Number(res.data.flag) === 1) {
|
||||
that.weixinPhone = true;
|
||||
} else {
|
||||
uni.showLoading({
|
||||
title: '登录中...'
|
||||
})
|
||||
that.$Request.postJson('/app/Login/ksRegister', {
|
||||
userName: nickName, //名称
|
||||
avatar: avatarUrl, //头像
|
||||
sex: sex, //性别
|
||||
// phone: '',
|
||||
inviterCode: invitationCode,
|
||||
ksOpenId: res.data.ksOpenId,
|
||||
qdCode: that.qdCodeion
|
||||
}).then(ress => {
|
||||
uni.hideLoading()
|
||||
if (ress.code == 0) {
|
||||
uni.setStorageSync('token', ress.token)
|
||||
uni.setStorageSync('userName', ress.user.userName)
|
||||
uni.setStorageSync('avatar', ress.user.avatar)
|
||||
uni.setStorageSync('phone', ress.user.phone)
|
||||
uni.setStorageSync('invitationCode', ress.user
|
||||
.invitationCode)
|
||||
if (ress.user.qdCode) {
|
||||
uni.setStorageSync('qdCode', ress.user.qdCode)
|
||||
}
|
||||
uni.setStorageSync('sex', ress.user.sex)
|
||||
uni.setStorageSync('userId', ress.user.userId)
|
||||
uni.setStorageSync('openId', ress.user.ksOpenId)
|
||||
that.$u.api.userVip({
|
||||
userId: uni.getStorageSync('userId')
|
||||
}).then(rest => {
|
||||
if (rest.code == 0 && rest.data && rest
|
||||
.data.isVip == 2) {
|
||||
uni.setStorageSync('isVIP', true)
|
||||
} else {
|
||||
uni.setStorageSync('isVIP', false)
|
||||
}
|
||||
})
|
||||
uni.navigateBack();
|
||||
} else {
|
||||
uni.showModal({
|
||||
showCancel: false,
|
||||
title: '登录失败',
|
||||
content: res.msg,
|
||||
});
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
|
||||
}
|
||||
});
|
||||
},
|
||||
getMyPhone(code) {
|
||||
let data = {
|
||||
code: code
|
||||
}
|
||||
this.$Request.postT('/app/Login/wxPhone', data).then(res => {
|
||||
if (res.code == 0) {
|
||||
this.phone = res.data.phone_info.purePhoneNumber;
|
||||
this.getWeixinInfo(this.sendDataList);
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '获取手机号失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
//小程序微信登录后获取手机号
|
||||
getPhoneNumber: function(e) {
|
||||
console.log(e.detail, '1111111111')
|
||||
// #ifdef MP-TOUTIAO
|
||||
if (e.detail.encryptedData && e.detail.iv) {
|
||||
if (e.detail.errMsg == 'getPhoneNumber:fail user deny') {
|
||||
console.log('用户拒绝提供手机号');
|
||||
} else {
|
||||
console.log('用户同意提供手机号');
|
||||
|
||||
// console.log('用户拒绝提供手机号');
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '获取手机号失败',
|
||||
icon: 'none'
|
||||
})
|
||||
// this.setPhoneByInsert(e.detail.encryptedData, e.detail.iv);
|
||||
this.setPhoneByInsert(e.detail.encryptedData, e.detail.iv);
|
||||
}
|
||||
// #endif
|
||||
// #ifdef MP-WEIXIN
|
||||
if (e.detail.code) {
|
||||
this.getMyPhone(e.detail.code)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '获取手机号失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
// if (e.detail.errMsg == 'getPhoneNumber:fail user deny') {
|
||||
// console.log('用户拒绝提供手机号');
|
||||
// } else {
|
||||
// console.log('用户同意提供手机号');
|
||||
// this.setPhoneByInsert(e.detail.encryptedData, e.detail.iv);
|
||||
// }
|
||||
// #endif
|
||||
// #ifdef MP-KUAISHOU
|
||||
|
||||
// #endif
|
||||
|
||||
},
|
||||
//小程序微信登录后获取手机号
|
||||
setPhoneByInsert(decryptData, iv) {
|
||||
@@ -928,6 +239,13 @@
|
||||
toLogin() {
|
||||
// this.$queue.loginClear();
|
||||
// let openid = this.$queue.getData('openid');
|
||||
if (!this.checked) {
|
||||
return this.$refs.uToast.show({
|
||||
title: '请阅读并同意《隐私政策》和《用户服务协议》',
|
||||
duration: 1500
|
||||
})
|
||||
}
|
||||
|
||||
let openid = uni.getStorageSync('openId')
|
||||
const {
|
||||
mobile,
|
||||
@@ -969,19 +287,19 @@
|
||||
uni.setStorageSync('invitationCode', res.user.invitationCode)
|
||||
uni.setStorageSync('sex', res.user.sex)
|
||||
uni.setStorageSync('userId', res.user.userId)
|
||||
uni.setStorageSync('openId', res.user.openId)
|
||||
//设置渠道码
|
||||
if (res.user.qdCode) {
|
||||
uni.setStorageSync('qdCode', res.user.qdCode)
|
||||
}
|
||||
// uni.setStorageSync('openId', res.user.openId)
|
||||
// this.getWeixinInfo(this.sendDataList);
|
||||
uni.showToast({
|
||||
title: '登录成功',
|
||||
icon: 'none'
|
||||
})
|
||||
setTimeout(function() {
|
||||
uni.switchTab({
|
||||
url: '/pages/index/index'
|
||||
});
|
||||
}, 1000)
|
||||
|
||||
|
||||
uni.navigateBack({
|
||||
delta: 2
|
||||
})
|
||||
} else {
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
@@ -1006,8 +324,7 @@
|
||||
avatar: sendData.avatar, //头像
|
||||
sex: sendData.sex, //性别
|
||||
phone: that.phone,
|
||||
inviterCode: sendData.inviterCode,
|
||||
qdCode: sendData.qdCode
|
||||
inviterCode: sendData.inviterCode
|
||||
};
|
||||
that.$u.api.insertWxUser(postData).then(res => {
|
||||
uni.hideLoading();
|
||||
@@ -1017,9 +334,6 @@
|
||||
uni.setStorageSync('avatar', res.user.avatar)
|
||||
uni.setStorageSync('phone', res.user.phone)
|
||||
uni.setStorageSync('invitationCode', res.user.invitationCode)
|
||||
if (res.user.qdCode) {
|
||||
uni.setStorageSync('qdCode', res.user.qdCode)
|
||||
}
|
||||
uni.setStorageSync('sex', res.user.sex)
|
||||
uni.setStorageSync('userId', res.user.userId)
|
||||
uni.setStorageSync('openId', res.user.openId)
|
||||
@@ -1043,15 +357,12 @@
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
button:after {
|
||||
border: none !important;
|
||||
}
|
||||
|
||||
.headers {
|
||||
text-align: center;
|
||||
}
|
||||
@@ -1062,14 +373,12 @@
|
||||
}
|
||||
|
||||
.footer {
|
||||
// padding-left: 150rpx;
|
||||
padding-left: 150rpx;
|
||||
margin-top: 32upx;
|
||||
font-size: 24upx;
|
||||
color: #666666;
|
||||
// text-align: center;
|
||||
text-align: center;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
page {
|
||||
@@ -1120,10 +429,9 @@
|
||||
}
|
||||
|
||||
.bottom {
|
||||
width: 686rpx;
|
||||
margin: 70rpx auto;
|
||||
line-height: 80upx;
|
||||
border-radius: 80upx;
|
||||
margin: 70rpx 50rpx;
|
||||
height: 80upx;
|
||||
font-size: 35rpx;
|
||||
}
|
||||
|
||||
BIN
static/action-bg.png
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
static/gift.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
static/git.png
Normal file
|
After Width: | Height: | Size: 440 B |
BIN
static/images/gift-bg.png
Normal file
|
After Width: | Height: | Size: 77 KiB |
BIN
static/images/gift-bg@2x.png
Normal file
|
After Width: | Height: | Size: 272 KiB |
BIN
static/images/lottery/gold.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
static/images/lottery/gold@2x.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
static/images/lottery/gold@3x.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
static/images/lottery/icon_xxhg.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
static/images/lottery/icon_xxhg@2x.png
Normal file
|
After Width: | Height: | Size: 7.0 KiB |
BIN
static/images/lottery/icon_xxhg@3x.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
static/images/lottery/icon_zhongjiang.png
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
static/images/lottery/icon_zhongjiang@2x.png
Normal file
|
After Width: | Height: | Size: 8.2 KiB |
BIN
static/images/lottery/icon_zhongjiang@3x.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
static/images/lottery/top-bg.png
Normal file
|
After Width: | Height: | Size: 618 KiB |
BIN
static/images/lottery/top-bg@2x.png
Normal file
|
After Width: | Height: | Size: 74 KiB |
BIN
static/images/lottery/top-bg@3x.png
Normal file
|
After Width: | Height: | Size: 164 KiB |
BIN
static/lottery-bg.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
static/red-pack.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
3
uni.scss
@@ -74,3 +74,6 @@ $uni-color-subtitle: #555555; // 二级标题颜色
|
||||
$uni-font-size-subtitle:36rpx;
|
||||
$uni-color-paragraph: #3F536E; // 文章段落颜色
|
||||
$uni-font-size-paragraph:30rpx;
|
||||
|
||||
$my-main-color:#318AFE;
|
||||
$my-red-color:#F02C45;
|
||||
249
uni_modules/almost-lottery/changelog.md
Normal file
@@ -0,0 +1,249 @@
|
||||
## 1.9.7(2023-08-02)
|
||||
本次更新:
|
||||
- 调整 `draw-before` 为自定义函数,且该函数为必备函数,转盘能否启动,将根据该函数中调用 `callback` 时传递的 `Boolean` 进行判断
|
||||
## 1.9.6.2(2023-07-28)
|
||||
本次更新:
|
||||
- 更新示例项目
|
||||
## 1.9.6.1(2023-07-28)
|
||||
本次更新:
|
||||
- 修复参数文档排版问题
|
||||
## 1.9.6(2023-07-28)
|
||||
本次更新:
|
||||
- 新增`drawStartBefore`钩子,请看说明文档
|
||||
## 1.9.5(2023-07-12)
|
||||
本次更新:
|
||||
- 优化 `duration` 参数的变更需要刷新才能生效的开发体验
|
||||
- 新增 `duration` 和 `ringCount` 设置不合理时的 `console` 提醒
|
||||
## 1.9.4(2023-07-06)
|
||||
本次更新:
|
||||
- 修复某些情况文字无法换行的问题
|
||||
- 参数`strMaxLen`设置为`0`时不限制文字长度
|
||||
## 1.9.3(2023-06-12)
|
||||
本次更新:
|
||||
- 新增 `selfTime` 参数,查看文档说明
|
||||
- 示例项目分离 `uni-popup` 用例为独立页面进行展示
|
||||
## 1.9.2(2023-05-22)
|
||||
本次更新:
|
||||
- 新增 `renderDelay` 参数,请查看文档
|
||||
- 示例项目新增 `ui-popup` 组件的用例,使用 `uni-popup` 包裹转盘时,请前往 `uni-popup` 组件文档关注平台兼容性问题
|
||||
## 1.9.1(2023-03-07)
|
||||
本次更新:
|
||||
- 新增 `selfRotaty` 自转参数,视觉效果上存在细微瑕疵,欢迎PR
|
||||
## 1.8.33(2022-07-04)
|
||||
本次更新:
|
||||
- 统一奖品图片下载方式
|
||||
## 1.8.32(2022-06-20)
|
||||
本次更新:
|
||||
- 调整平台兼容性(因 HBX 存在 bug,导致平台兼容性的更新多次失败,近几次的更新都可以忽略)
|
||||
## 1.8.31(2022-06-20)
|
||||
本次更新:
|
||||
- 无意义的更新,请忽略
|
||||
## 1.8.30(2022-06-20)
|
||||
本次更新:
|
||||
- 调整平台兼容性
|
||||
## 1.8.29(2022-06-19)
|
||||
本次更新:
|
||||
- 调整平台兼容信息
|
||||
## 1.8.28(2022-06-19)
|
||||
本次更新:
|
||||
- 修复单个尺寸过大的 canvas 在 H5/APP-vue iOS/Safari 中存在可能无法绘制成功的问题
|
||||
## 1.8.27(2022-06-01)
|
||||
本次更新:
|
||||
- 优化示例项目
|
||||
## 1.8.26(2022-06-01)
|
||||
本次更新:
|
||||
- 修复奖品图片裁切为圆形时在安卓机器不显示的问题
|
||||
## 1.8.25(2022-05-31)
|
||||
本次更新:
|
||||
- 修复部分安卓下载图片得到.unknown格式文件的问题
|
||||
## 1.8.24(2022-05-09)
|
||||
本地缓存:
|
||||
- 优化示例项目
|
||||
## 1.8.23(2022-05-09)
|
||||
本地缓存:
|
||||
- 优化清除文件缓存的方法
|
||||
## 1.8.22(2022-05-09)
|
||||
本次更新:
|
||||
- 调整计算转盘绘制的方式
|
||||
## 1.8.21(2022-05-08)
|
||||
本次更新:
|
||||
- 调整示例项目中本地图片的引入方式
|
||||
## 1.8.20(2022-04-29)
|
||||
本次更新:
|
||||
- 修复转盘在某个临界点可以出现多次触发的问题
|
||||
## 1.8.19(2022-04-27)
|
||||
本次更新:
|
||||
- 奖品文字的绘制由先前的两行变成多行,根据设定的每行文字的长度分段绘制
|
||||
## 1.8.18(2022-04-25)
|
||||
本次更新:
|
||||
- 减少小程序平台的 delay
|
||||
## 1.8.17(2022-03-23)
|
||||
本次更新:
|
||||
- 新增配置项 `imgCircled` 奖品图片是否裁切为圆形,默认不裁切
|
||||
## 1.8.16(2022-03-04)
|
||||
本次更新:
|
||||
- 示例项目新增绘制时长的计算,方便开发时定位绘制慢的问题
|
||||
## 1.8.15(2022-03-02)
|
||||
本次更新:
|
||||
- 优化一处错误提示信息的展现方式
|
||||
## 1.8.14(2021-11-29)
|
||||
本次更新:
|
||||
- 示例项目中新增开放自定义权重最大值,没有自定义则取权重数组中的最大值
|
||||
- 更新文档
|
||||
## 1.8.13(2021-11-03)
|
||||
本次更新:
|
||||
- 注释 `1.8.12` 版本中调试时的代码
|
||||
## 1.8.12(2021-11-03)
|
||||
本次更新:
|
||||
- 修复一些老机型不支持 `flex` 导致布局错乱的问题
|
||||
## 1.8.11(2021-10-29)
|
||||
本次更新:
|
||||
- 优化示例项目中模拟接口访问的速度
|
||||
## 1.8.10(2021-10-19)
|
||||
本次更新:
|
||||
- 优化组件代码
|
||||
- 更新示例项目
|
||||
## 1.8.9(2021-09-28)
|
||||
本次更新:
|
||||
- 移除内置的 `奖品准备中...` 提示
|
||||
## 1.8.8(2021-09-27)
|
||||
本次更新:
|
||||
- 修复 `1.8.6` 引起的非微信小程序平台绘制异常的问题
|
||||
## 1.8.7(2021-09-23)
|
||||
本次更新:
|
||||
- 优化项目中使用到的图片大小
|
||||
## 1.8.6(2021-09-23)
|
||||
本次更新:
|
||||
- 修复小程序平台在绘制 `base64` 格式的图片时无法在真机模式下正常显示的问题
|
||||
## 1.8.5(2021-09-13)
|
||||
本次更新:
|
||||
- 修复一个已知问题
|
||||
## 1.8.4(2021-09-12)
|
||||
本次更新:
|
||||
- 调整 `strFontColor` 为 `strFontColors`,现在可以设置每个区块的文字颜色,详见文档说明
|
||||
## 1.8.3(2021-09-12)
|
||||
本次更新:
|
||||
- 修复因 `1.8.0` 改动引起的文字方向、无奖品图时绘制异常的问题
|
||||
- 新增 `imgDrawed` 是否绘制奖品图片的配置项 ,默认为 `true`
|
||||
## 1.8.2(2021-09-10)
|
||||
本次更新:
|
||||
**不兼容旧版本的更新**
|
||||
- 移除配置项 `strKey` 字段
|
||||
- 调整 `prizeList` 结构
|
||||
## 1.8.1(2021-09-06)
|
||||
本次更新:
|
||||
- 修复 `hbx3.1.22` 在小程序平台处理 `id-name` 存在解析错误的问题
|
||||
## 1.8.0(2021-09-06)
|
||||
本次更新:
|
||||
**该版本更新涉及破坏性的变更,请重新查看 `API - Props` 的部分**
|
||||
- `px` 全面调整为 `rpx` 单位,多个`Props` 的参数相应调整,请查看文档
|
||||
- 新增 `pixelRatio` 参数,该参数为设计稿的设备像素比基准值,默认为 `2` 倍素
|
||||
## 1.7.18(2021-09-05)
|
||||
本次更新:
|
||||
- 修复一个已知问题
|
||||
## 1.7.17(2021-08-23)
|
||||
本次更新:
|
||||
- 更新示例项目
|
||||
## 1.7.16(2021-08-14)
|
||||
本次更新:
|
||||
- 更新示例项目
|
||||
## 1.7.15(2021-08-03)
|
||||
本次更新:
|
||||
- 新增文字竖向展示的功能,详见文档说明
|
||||
## 1.7.13(2021-08-02)
|
||||
本次更新:
|
||||
- 更新文档
|
||||
## 1.7.12(2021-07-30)
|
||||
本次更新:
|
||||
- 修复示例项目的已知问题
|
||||
- 现已提供Almost-Lottery抽奖转盘的uniCloud云端一体页面模板
|
||||
- 现已提供Almost-Lottery抽奖转盘云端一体页面配套的Admin配置中心
|
||||
## 1.7.11(2021-07-22)
|
||||
本次更新:
|
||||
- 修复部分安卓手机文字大小异常的问题
|
||||
- 字段 `strHeightMultiple` 更换为 `strLineHeight`
|
||||
## 1.7.10(2021-07-12)
|
||||
本次更新:
|
||||
- 修复奖品名称 `name` 为空字符串时无法成功绘制转盘的问题
|
||||
- 新增 `prizeNameDrawed` 是否绘制奖品名称的配置项,现在可以仅展示奖品图片了
|
||||
## 1.7.9(2021-07-09)
|
||||
本次更新:
|
||||
- 优化组件内部代码
|
||||
- 修复奖品图片已然是 `base64` 格式时导致转盘绘制失败的问题
|
||||
- 文档新增QQ群号,让沟通更便捷
|
||||
## 1.7.8(2021-07-08)
|
||||
本次更新:
|
||||
- 调整 `Canvas` 默认宽高为 `280`
|
||||
## 1.7.7(2021-07-08)
|
||||
本次更新:
|
||||
- 新增多个配置项,满足更多自定义需求
|
||||
- 优化多行文本情况下非中文字符的字节处理
|
||||
- 修复偶发的第一条数据文本不居中显示的问题
|
||||
## 1.7.6(2021-07-02)
|
||||
本次更新:
|
||||
- 调整 `imageWidth` 、 `imageHeight` 字段为 `imgWidth` 、 `imgHeight`
|
||||
- 更新示例项目
|
||||
## 1.7.5(2021-07-01)
|
||||
本次更新:
|
||||
- 新增配置项 `imgMarginStr` 奖品图片距离奖品文字的距离
|
||||
## 1.7.4(2021-06-28)
|
||||
本次更新:
|
||||
- 新增轮盘旋转或指针旋转配置项
|
||||
- 转盘内置的外环图片以及按钮图片统一调整为 `image` 展示
|
||||
- 更新相关文档说明
|
||||
## 1.7.3(2021-06-16)
|
||||
本次更新:
|
||||
- 优化错误提示
|
||||
- 优化示例项目
|
||||
- 优化文档说明
|
||||
## 1.7.2(2021-06-11)
|
||||
本次更新:
|
||||
- 新增 `canvasId` 参数配置项,多画板情况下需要配置不同的 `canvasId`
|
||||
- 优化多画板情况下的缓存功能
|
||||
- 优化示例项目
|
||||
- 修改文档说明
|
||||
## 1.7.1(2021-06-10)
|
||||
本次更新:
|
||||
- 优化示例项目中的注释
|
||||
## 1.7.0(2021-06-04)
|
||||
本次更新:
|
||||
- 修复 `1.6.1` 引起的多行奖品文字行高异常的问题
|
||||
- 新增配置转盘外环和抽奖按钮图片的功能,详见文档说明
|
||||
- 更新示例项目,新增抽奖次数等业务有关的逻辑供参考
|
||||
## 1.6.1(2021-05-28)
|
||||
本次更新:
|
||||
- 修复小程序平台画板模糊的问题
|
||||
## 1.6.0(2021-05-28)
|
||||
本次更新:
|
||||
- 新增奖品区块是否开启描边的配置项,默认不开启
|
||||
- 调整画板缓存为默认不开启
|
||||
- 优化代码
|
||||
- 优化文档说明
|
||||
- 更新示例项目并修改部分注释
|
||||
## 1.5.13(2021-05-22)
|
||||
本次更新:
|
||||
- 优化文档说明
|
||||
- 更新示例项目
|
||||
## 1.5.12(2021-05-22)
|
||||
本次更新:
|
||||
- 新增配置项 `strokeColor` 奖品区块边框颜色
|
||||
- 更新文档说明
|
||||
## 1.5.11(2021-05-19)
|
||||
本次更新:
|
||||
- 新增`strMarginOutside`参数,用于设置奖品文字距离边缘的距离
|
||||
- 修复奖品文字在某些情况下不是居中显示的问题
|
||||
## 1.5.10(2021-05-19)
|
||||
本次更新:
|
||||
- 修复示例项目中权重值相同时的取值逻辑
|
||||
## 1.5.9(2021-05-14)
|
||||
本次更新:
|
||||
- 调整代码,优化小程序端的展示
|
||||
## 1.5.8(2021-05-12)
|
||||
本次更新:
|
||||
- 文档增加预警提示:不再维护非 `uni_modules` 模式下的版本
|
||||
## 1.5.7(2021-05-12)
|
||||
本次更新:
|
||||
- 修复小程序平台奖品名称不清晰的问题
|
||||
## 1.5.6(2021-03-18)
|
||||
本次更新:
|
||||
- 适配 uni_modules 插件模式
|
||||
85
uni_modules/almost-lottery/package.json
Normal file
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"id": "almost-lottery",
|
||||
"displayName": "Almost-Lottery抽奖转盘",
|
||||
"version": "1.9.7",
|
||||
"description": "【荣获2021插件大赛三等奖】提供奇数、缓存等众多配置项,更有抽奖概率、抽奖次数、付费抽奖等功能内置于示例项目中,完美支持APP、各平台小程序、H5、PC,同时提供 uniCloud 云端版本",
|
||||
"keywords": [
|
||||
"转盘",
|
||||
"抽奖",
|
||||
"转盘抽奖",
|
||||
"大转盘",
|
||||
"大转盘抽奖"
|
||||
],
|
||||
"repository": "https://github.com/ialmost/almost-components_uniapp",
|
||||
"engines": {
|
||||
"HBuilderX": "^3.7.11"
|
||||
},
|
||||
"dcloudext": {
|
||||
"sale": {
|
||||
"regular": {
|
||||
"price": "0.00"
|
||||
},
|
||||
"sourcecode": {
|
||||
"price": "0.00"
|
||||
}
|
||||
},
|
||||
"contact": {
|
||||
"qq": ""
|
||||
},
|
||||
"declaration": {
|
||||
"ads": "无",
|
||||
"data": "无",
|
||||
"permissions": "无"
|
||||
},
|
||||
"npmurl": "",
|
||||
"type": "component-vue"
|
||||
},
|
||||
"uni_modules": {
|
||||
"dependencies": [],
|
||||
"encrypt": [],
|
||||
"platforms": {
|
||||
"cloud": {
|
||||
"tcb": "y",
|
||||
"aliyun": "y"
|
||||
},
|
||||
"client": {
|
||||
"App": {
|
||||
"app-vue": "y",
|
||||
"app-nvue": "n"
|
||||
},
|
||||
"H5-mobile": {
|
||||
"Safari": "y",
|
||||
"Android Browser": "y",
|
||||
"微信浏览器(Android)": "y",
|
||||
"QQ浏览器(Android)": "y"
|
||||
},
|
||||
"H5-pc": {
|
||||
"Chrome": "y",
|
||||
"IE": "y",
|
||||
"Edge": "y",
|
||||
"Firefox": "y",
|
||||
"Safari": "y"
|
||||
},
|
||||
"小程序": {
|
||||
"微信": "y",
|
||||
"阿里": "y",
|
||||
"百度": "y",
|
||||
"字节跳动": "y",
|
||||
"QQ": "y",
|
||||
"钉钉": "y",
|
||||
"快手": "y",
|
||||
"飞书": "y",
|
||||
"京东": "y"
|
||||
},
|
||||
"快应用": {
|
||||
"华为": "u",
|
||||
"联盟": "u"
|
||||
},
|
||||
"Vue": {
|
||||
"vue2": "y",
|
||||
"vue3": "n"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
174
uni_modules/almost-lottery/readme.md
Normal file
@@ -0,0 +1,174 @@
|
||||
# almost-lottery
|
||||
*使用 Canvas 绘制的抽奖转盘,提供奇数、缓存等众多配置项,更有抽奖概率、抽奖次数、付费抽奖等功能内置于示例项目中*
|
||||
|
||||
|
||||
> <br />
|
||||
>
|
||||
> 如果用着还行,请支持一下
|
||||
> - 前往 [GitHub](https://github.com/ialmost/almost-components_uniapp) 给个 Star
|
||||
> - 前往 [UniApp](https://ext.dcloud.net.cn/plugin?id=1030) 给个五星
|
||||
> - 使用中遇到问题时,可以添加 **QQ群 20441313**
|
||||
>
|
||||
> <br />
|
||||
|
||||
|
||||
## 基于 uniCloud 开发的云端 Almost-Lottery 抽奖转盘,欢迎尝试体验
|
||||
- [Almost-Lottery抽奖转盘的云端一体页面](https://ext.dcloud.net.cn/plugin?id=5763)
|
||||
- [Almost-Lottery抽奖转盘的配置中心](https://ext.dcloud.net.cn/plugin?id=5762)
|
||||
|
||||
|
||||
## 高能预警
|
||||
- 本插件仅支持 `uni_modules` 模式,强烈推荐使用该模式,**非 `uni_modules` 模式不再维护**
|
||||
- 在使用本插件之前,强烈建议使用 `HBuilderX` 导入示例项目验证可用性并参照修改
|
||||
|
||||
## 功能概要
|
||||
- [x] 可配置奖品文字 **支持横向/竖向展示**
|
||||
- [x] 可配置每个奖品区块的背景颜色
|
||||
- [x] 可配置每个奖品区块的奖品文字颜色
|
||||
- [x] 可配置奖品区块是否开启描边以及边框的颜色,默认不开启
|
||||
- [x] 可配置转盘外环和抽奖按钮图
|
||||
- [x] 可配置每个奖品区块的奖品图片,**当图片是网络地址时,小程序端需要配置白名单,H5端需要允许跨域,奖品文字为竖向时不支持展示奖品图片**
|
||||
- [x] 奖品列表支持奇数,**奇数时需尽量能被 `360` 除尽**
|
||||
- [x] 可配置内圈与外圈的间距
|
||||
- [x] 可配置轮盘旋转或指针旋转
|
||||
- [x] 可配置画板是否缓存,默认不开启
|
||||
- [x] 更多配置请查看API说明
|
||||
|
||||
## 示例项目附加功能
|
||||
- [x] 中奖概率,**强烈推荐中奖概率应由后端控制**
|
||||
- [x] 抽奖次数
|
||||
- [x] 付费抽奖
|
||||
|
||||
|
||||
## 注意事项
|
||||
|
||||
- 编译到小程序端时,请务必勾选ES6转ES5
|
||||
|
||||
- `@reset-index="prizeIndex = -1"` 必须默认写入到 `template` 中,不可删除
|
||||
|
||||
- 每个奖品区块的奖品图片尺寸不宜过大,图片越大,绘制的过程越慢,尽量将图片尺寸控制在 `100*100` 以内,且图片大小控制在 `40KB` 以内
|
||||
|
||||
- 关于中奖概率的配置,请下载示例项目,参照 `pages/index/index.vue` 中的代码进行配置
|
||||
|
||||
- 组件本身不涉及任何业务逻辑,与业务相关的代码建议都放在 `pages/index/index.vue` 中
|
||||
|
||||
|
||||
## 代码演示
|
||||
#### 基础用法
|
||||
```
|
||||
// template
|
||||
// @reset-index="prizeIndex = -1" 必须默认写入到 template 中,不可删除
|
||||
<almost-lottery
|
||||
:prizeList="prizeList"
|
||||
:prizeIndex="prizeIndex"
|
||||
@reset-index="prizeIndex = -1"
|
||||
@draw-before="handleDrawBefore"
|
||||
@draw-start="handleDrawStart"
|
||||
@draw-end="handleDrawEnd"
|
||||
@finish="handleDrawFinish"
|
||||
v-if="prizeList.length"
|
||||
/>
|
||||
|
||||
// script
|
||||
import AlmostLottery from '@/uni_modules/almost-lottery/components/almost-lottery/almost-lottery.vue'
|
||||
export default {
|
||||
components: {
|
||||
AlmostLottery
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
// 以下是奖品配置数据
|
||||
// 奖品数据
|
||||
prizeList: [],
|
||||
// 中奖下标
|
||||
prizeIndex: -1
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 本次抽奖开始之前
|
||||
handleDrawStart (callback) {
|
||||
// 这里需要处理你抽奖之前的逻辑
|
||||
// 请查看示例项目中的代码
|
||||
// 必须调用 callback 并传递一个布尔值,布尔值为 true 时,转盘才会开始旋转
|
||||
let flag = true
|
||||
|
||||
callback(flag)
|
||||
},
|
||||
// 本次抽奖开始
|
||||
handleDrawStart () {
|
||||
// 这里需要处理你的抽奖逻辑,并得出中奖物品的 prizeIndex
|
||||
// 请查看示例项目中的代码
|
||||
},
|
||||
// 本次抽奖结束
|
||||
handleDrawEnd () {
|
||||
// 完成抽奖后,这里处理你拿到结果后的逻辑
|
||||
// 请查看示例项目中的代码
|
||||
},
|
||||
// 抽奖转盘绘制完成
|
||||
handleDrawFinish (res) {
|
||||
// 抽奖转盘准备就绪后,这里处理你的逻辑
|
||||
// 请查看示例项目中的代码
|
||||
// console.log('抽奖转盘绘制完成', res)
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## API
|
||||
#### Props
|
||||
参数 | 说明 | 类型 | 默认值
|
||||
:---|:---|:---|:---
|
||||
pixelRatio | 移动端设计稿的像素比基准值,**涉及到 `rpx` 的适配问题** | *`Number`* | `2`
|
||||
canvasId | Canvas的标识,**多画板情况下需要配置不同的标识** | *`String`* | `'almostLottery'`
|
||||
renderDelay | 转盘的渲染延时,**转盘被包裹在 uni-popup 组件内且开启了动画,请设置成最少 300** | *`Number`* | `0`
|
||||
lotterySize | 抽奖转盘的整体尺寸,单位 `rpx` | *`Number`* | `600`
|
||||
actionSize | 抽奖按钮的尺寸,单位 `rpx` | *`Number`* | `200`
|
||||
canvasMarginOutside | Canvas边缘距离转盘边缘的距离,单位`rpx` | *`Number`* | `90`
|
||||
prizeIndex | 获奖奖品在奖品列表中的序号,**每次抽奖结束后会自动重置为 `-1`** | *`Number`* | `-1`
|
||||
prizeList | 奖品列表,支持奇数(尽量能被 `360` 除尽),**为奇数时需要重设 `colors` 参数** | *`Array`* | -
|
||||
lotteryBg | 转盘外环图片 | `String` | `默认内置的本地图片`
|
||||
actionBg | 抽奖按钮图片 | `String` | `默认内置的本地图片`
|
||||
colors | 奖品区块对应的背景颜色,默认 2 个颜色相互交替,**也可以对每个区块设置不同颜色** | *`Array`* | `['#FFFFFF', '#FFBF05']`
|
||||
prizeNameDrawed | 是否绘制奖品名称 | *`Boolean`* | `true`
|
||||
stroked | 是否开启奖品区块描边 | *`Boolean`* | `false`
|
||||
strDirection | 奖品名称展示方向,可选值 `'horizontal'` => 横向 `'vertical'` => 竖向 | *`String`* | `'horizontal'`
|
||||
strokeColor | 奖品区块边框颜色 | *`String`* | `'#FFBF05'`
|
||||
rotateType | 旋转的类型,可选值 `'roulette'` => 轮盘旋转 `'pointer'` => 指针旋转 | *`String`* | `'roulette'`
|
||||
selfRotaty | 是否开启自转,开启后`duration`和`ringCount`参数不生效 | *`Boolean`* | `false`
|
||||
selfTime | 开启自转时,最少转多少毫秒 | *`Number`* | `1000`
|
||||
duration | 转盘旋转的动画时长,单位:秒 | *`Number`* | `8`
|
||||
ringCount | 旋转的圈数 | *`Number`* | `8`
|
||||
pointerPosition | 点击抽奖按钮指针的位置,可选值 `'edge'` => 指向边界 `'middle'` => 指向中间 | *`String`* | `'edge'`
|
||||
strFontColors | 奖品文字颜色,默认 2 个颜色相互交替,**也可以对每个区块的文字设置不同颜色,或仅设置一个颜色** | *`Array`* | `['#FFBF05', '#FFFFFF']`
|
||||
strFontSize | 奖品名称的字号,单位 `rpx` | *`Number`* | `24`
|
||||
strLineHeight | 奖品名称多行情况下的行高 | *`Number`* | `1.2`
|
||||
strMaxLen | 奖品名称长度限制,为`0`时不限制,**文字竖向时不生效** | *`Number`* | `12`
|
||||
strLineLen | 奖品名称在多行情况下第一行文字的长度,**文字竖向时不生效** | *`Number`* | `6`
|
||||
strMarginOutside | 奖品文字相对轮盘边缘的距离,单位 `rpx` | *`Number`* | `strFontSize 的一半`
|
||||
imgMarginStr | 奖品图片相对奖品文字的距离,单位 `rpx` | *`Number`* | `60`
|
||||
imgWidth | 奖品图片的宽度,单位 `rpx` | *`Number`* | `50`
|
||||
imgHeight | 奖品图片的高度,单位 `rpx` | *`Number`* | `50`
|
||||
imgDrawed | 是否绘制奖品图片,默认绘制 | *`Boolean`* | `true`
|
||||
imgCircled | 奖品图片是否裁切为圆形,默认不裁切 | *`Boolean`* | `false`
|
||||
successMsg | 转盘绘制成功的提示 | *`String`* | `'奖品准备就绪,快来参与抽奖吧'`
|
||||
failMsg | 转盘绘制失败的提示 | *`String`* | `'奖品仍在准备中,请稍后再来...'`
|
||||
canvasCached | 是否开启缓存,避免在数据不变的情况下重复绘制,建议在生产环境中开启 | *`Boolean`* | `false`
|
||||
|
||||
#### Events
|
||||
事件名 | 说明 | 回调参数
|
||||
:---|:---|:---|:---
|
||||
@reset-index | 每次抽奖结束后重置获奖的序号为 `-1`,**该事件必须默认写入到 `template` 中,不可删除** | -
|
||||
@draw-before | 转盘旋转之前触发,**该事件必须默认写入到 `template` 中,不可删除** | `callback(Boolean)`
|
||||
@draw-start | 转盘旋转开始时触发 | -
|
||||
@draw-end | 转盘旋转结束时触发 | -
|
||||
@finish | Canvas转盘绘制完成时触发 | `{ ok: 绘制是否成功, data: 转盘的图片, msg: 绘制结果的提示 }`
|
||||
|
||||
#### prizeList 数据结构
|
||||
*请按如下数据字段对你的奖品列表数据结构进行调整*
|
||||
键名 | 说明 | 类型
|
||||
:---|:---|:---
|
||||
prizeId | 奖品对应 `ID` | *`Number`*
|
||||
prizeName | 奖品名称 | *`String`*
|
||||
prizeStock | 奖品库存 | *`Number`*
|
||||
prizeWeight | 奖品权重 | *`Number`*
|
||||
prizeImage | 奖品图片地址,网络图片仅支持`http`和`https`协议 | *`String`*
|
||||
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 9.1 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 13 KiB |
298
uni_modules/almost-lottery/utils/almost-utils.js
Normal file
@@ -0,0 +1,298 @@
|
||||
/**
|
||||
* 存储 localStorage 数据
|
||||
* @param {String} name - 缓存数据的标识
|
||||
* @param {any} content - 缓存的数据内容
|
||||
*/
|
||||
export const setStore = (name, content) => {
|
||||
if (!name) return
|
||||
if (typeof content !== 'string') {
|
||||
content = JSON.stringify(content)
|
||||
}
|
||||
uni.setStorageSync(name, content)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 localStorage 数据
|
||||
* @param {String} name - 缓存数据的标识
|
||||
*/
|
||||
export const getStore = (name) => {
|
||||
if (!name) return
|
||||
return uni.getStorageSync(name)
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除 localStorage 数据
|
||||
* @param {String} name - 缓存数据的标识
|
||||
*/
|
||||
export const clearStore = (name) => {
|
||||
if (name) {
|
||||
uni.removeStorageSync(name)
|
||||
} else {
|
||||
console.log('清理本地全部缓存')
|
||||
uni.clearStorageSync()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制圆形
|
||||
* @param {String} ctx - 图片网络地址
|
||||
* @param {String} img - 图片地址
|
||||
* @param {String} x - x 轴偏移量
|
||||
* @param {String} y - y 轴偏移量
|
||||
* @param {String} w - 宽
|
||||
* @param {String} h - 高
|
||||
*/
|
||||
export const circleImg = (ctx, img, x, y, w, h) => {
|
||||
let r = Math.floor(w/2)
|
||||
let cx = x + r
|
||||
let cy = y + r
|
||||
|
||||
ctx.save()
|
||||
ctx.beginPath()
|
||||
ctx.arc(cx, cy, r, 0, Math.PI * 2)
|
||||
ctx.fill()
|
||||
ctx.clip()
|
||||
ctx.drawImage(img, x, y, w, h)
|
||||
ctx.restore()
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算文本的长度
|
||||
* @param {String} text - 文本内容
|
||||
*/
|
||||
export const clacTextLen = (text) => {
|
||||
if (!text) return { byteLen: 0, realLen: 0 }
|
||||
text += ''
|
||||
let clacLen = 0
|
||||
for (let i = 0; i < text.length; i++) {
|
||||
if ((text.charCodeAt(i) < 0) || (text.charCodeAt(i) > 255)) {
|
||||
clacLen += 2
|
||||
} else {
|
||||
clacLen += 1
|
||||
}
|
||||
}
|
||||
// console.log(`当前文本 ${text} 的长度为 ${clacLen / 2}`)
|
||||
return {
|
||||
byteLen: clacLen,
|
||||
realLen: clacLen / 2
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文件,并返回临时路径
|
||||
* @return {String} 临时路径
|
||||
* @param {String} fileUrl - 网络地址
|
||||
*/
|
||||
export const downloadFile = (fileUrl) => {
|
||||
return new Promise((resolve) => {
|
||||
uni.downloadFile({
|
||||
url: fileUrl,
|
||||
success: (res) => {
|
||||
resolve({
|
||||
ok: true,
|
||||
data: res.errMsg,
|
||||
tempFilePath: res.tempFilePath
|
||||
})
|
||||
},
|
||||
fail: (err) => {
|
||||
resolve({
|
||||
ok: false,
|
||||
data: err.errMsg,
|
||||
msg: '图片下载失败'
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理应用已缓存的文件
|
||||
*/
|
||||
export const clearCacheFile = () => {
|
||||
// #ifndef H5
|
||||
uni.getSavedFileList({
|
||||
success: (res) => {
|
||||
let fileList = res.fileList
|
||||
if (fileList.length) {
|
||||
for (let i = 0; i < fileList.length; i++) {
|
||||
uni.removeSavedFile({
|
||||
filePath: fileList[i].filePath,
|
||||
complete: () => {
|
||||
console.log('清除缓存已完成')
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log('getSavedFileList Fail')
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 图像转换工具,可用于图像和base64的转换
|
||||
// https://ext.dcloud.net.cn/plugin?id=123
|
||||
const getLocalFilePath = (path) => {
|
||||
if (
|
||||
path.indexOf('_www') === 0 ||
|
||||
path.indexOf('_doc') === 0 ||
|
||||
path.indexOf('_documents') === 0 ||
|
||||
path.indexOf('_downloads') === 0
|
||||
) return path
|
||||
|
||||
if (path.indexOf('/storage/emulated/0/') === 0) return path
|
||||
|
||||
if (path.indexOf('/storage/sdcard0/') === 0) return path
|
||||
|
||||
if (path.indexOf('/var/mobile/') === 0) return path
|
||||
|
||||
if (path.indexOf('file://') === 0) return path
|
||||
|
||||
if (path.indexOf('/') === 0) {
|
||||
// ios 无法获取本地路径
|
||||
let localFilePath = plus.os.name === 'iOS' ? path : plus.io.convertLocalFileSystemURL(path)
|
||||
if (localFilePath !== path) {
|
||||
return localFilePath
|
||||
} else {
|
||||
path = path.substring(1)
|
||||
}
|
||||
}
|
||||
|
||||
return '_www/' + path
|
||||
}
|
||||
|
||||
export const pathToBase64 = (path) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (typeof window === 'object' && 'document' in window) {
|
||||
if (typeof FileReader === 'function') {
|
||||
let xhr = new XMLHttpRequest()
|
||||
xhr.open('GET', path, true)
|
||||
xhr.responseType = 'blob'
|
||||
xhr.onload = function() {
|
||||
if (this.status === 200) {
|
||||
let fileReader = new FileReader()
|
||||
fileReader.onload = function(e) {
|
||||
resolve(e.target.result)
|
||||
}
|
||||
fileReader.onerror = reject
|
||||
fileReader.readAsDataURL(this.response)
|
||||
}
|
||||
}
|
||||
xhr.onerror = reject
|
||||
xhr.send()
|
||||
return
|
||||
}
|
||||
let canvas = document.createElement('canvas')
|
||||
let c2x = canvas.getContext('2d')
|
||||
let img = new Image
|
||||
img.onload = function() {
|
||||
canvas.width = img.width
|
||||
canvas.height = img.height
|
||||
c2x.drawImage(img, 0, 0)
|
||||
resolve(canvas.toDataURL())
|
||||
canvas.height = canvas.width = 0
|
||||
}
|
||||
img.onerror = reject
|
||||
img.src = path
|
||||
return
|
||||
}
|
||||
|
||||
if (typeof plus === 'object') {
|
||||
let tempPath = getLocalFilePath(path)
|
||||
plus.io.resolveLocalFileSystemURL(tempPath, (entry) => {
|
||||
entry.file((file) => {
|
||||
let fileReader = new plus.io.FileReader()
|
||||
fileReader.onload = function(data) {
|
||||
resolve(data.target.result)
|
||||
}
|
||||
fileReader.onerror = function(error) {
|
||||
console.log(error)
|
||||
reject(error)
|
||||
}
|
||||
fileReader.readAsDataURL(file)
|
||||
}, (error) => {
|
||||
reject(error)
|
||||
})
|
||||
}, (error) => {
|
||||
reject(error)
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (typeof wx === 'object' && wx.canIUse('getFileSystemManager')) {
|
||||
wx.getFileSystemManager().readFile({
|
||||
filePath: path,
|
||||
encoding: 'base64',
|
||||
success: (res) => {
|
||||
resolve('data:image/png;base64,' + res.data)
|
||||
},
|
||||
fail: (error) => {
|
||||
reject(error)
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
reject(new Error('not support'))
|
||||
})
|
||||
}
|
||||
|
||||
export const base64ToPath = (base64) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (typeof window === 'object' && 'document' in window) {
|
||||
base64 = base64.split(',')
|
||||
let type = base64[0].match(/:(.*?);/)[1]
|
||||
let str = atob(base64[1])
|
||||
let n = str.length
|
||||
let array = new Uint8Array(n)
|
||||
while (n--) {
|
||||
array[n] = str.charCodeAt(n)
|
||||
}
|
||||
return resolve((window.URL || window.webkitURL).createObjectURL(new Blob([array], {
|
||||
type: type
|
||||
})))
|
||||
}
|
||||
let extName = base64.match(/data\:\S+\/(\S+);/)
|
||||
if (extName) {
|
||||
extName = extName[1]
|
||||
} else {
|
||||
reject(new Error('base64 error'))
|
||||
}
|
||||
let fileName = Date.now() + '.' + extName
|
||||
if (typeof plus === 'object') {
|
||||
let bitmap = new plus.nativeObj.Bitmap('bitmap' + Date.now())
|
||||
bitmap.loadBase64Data(base64, () => {
|
||||
let filePath = '_doc/uniapp_temp/' + fileName
|
||||
bitmap.save(filePath, {}, () => {
|
||||
bitmap.clear()
|
||||
resolve(filePath)
|
||||
}, (error) => {
|
||||
bitmap.clear()
|
||||
reject(error)
|
||||
})
|
||||
}, (error) => {
|
||||
bitmap.clear()
|
||||
reject(error)
|
||||
})
|
||||
return
|
||||
}
|
||||
if (typeof wx === 'object' && wx.canIUse('getFileSystemManager')) {
|
||||
let filePath = wx.env.USER_DATA_PATH + '/' + fileName
|
||||
wx.getFileSystemManager().writeFile({
|
||||
filePath: filePath,
|
||||
data: base64.replace(/^data:\S+\/\S+;base64,/, ''),
|
||||
encoding: 'base64',
|
||||
success: () => {
|
||||
resolve(filePath)
|
||||
},
|
||||
fail: (error) => {
|
||||
reject(error)
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
reject(new Error('not support'))
|
||||
})
|
||||
}
|
||||