|
@@ -1,5 +1,6 @@
|
|
// pages/integral/integral.js
|
|
// pages/integral/integral.js
|
|
import Integralinfo from '../../api/integralinfo'
|
|
import Integralinfo from '../../api/integralinfo'
|
|
|
|
+import {getMobileCache, getPhoneNumberNew as getPhoneNumberSync} from '../../utils/user'
|
|
Page({
|
|
Page({
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -19,13 +20,49 @@ Page({
|
|
scorePhone: false,
|
|
scorePhone: false,
|
|
animationData: {},
|
|
animationData: {},
|
|
integralIngo:{},
|
|
integralIngo:{},
|
|
|
|
+ loading: false,
|
|
|
|
+ setPhone: '',
|
|
|
|
+ current: '',
|
|
|
|
+ integralNum: 0,
|
|
|
|
+ phone: '********',
|
|
|
|
+ // phone: '15888282621',
|
|
|
|
+ mobile: '********',
|
|
|
|
+ paymentStatus: false,
|
|
|
|
+ paymentBgStatus: false,
|
|
|
|
+ activeNum: 0,
|
|
|
|
+ listTrue: [],
|
|
|
|
+ listStatus: false,
|
|
|
|
+ total: 0,
|
|
|
|
+ row: {},
|
|
|
|
+ codeName: '60s后重新获取',
|
|
|
|
+ codeTime: '',
|
|
|
|
+ active1obj: {
|
|
|
|
+ orderId: '',
|
|
|
|
+ order_no: '',
|
|
|
|
+ step: ''
|
|
|
|
+ },
|
|
|
|
+ active1code: '',
|
|
|
|
+ active2code: '',
|
|
|
|
+ tgid: '',
|
|
|
|
+ scene: '',
|
|
|
|
+ noClick: true,
|
|
|
|
+ showToastObj: {
|
|
|
|
+ icon: '',
|
|
|
|
+ title: '',
|
|
|
|
+ status: false
|
|
|
|
+ }
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
*/
|
|
onLoad: function (options) {
|
|
onLoad: function (options) {
|
|
-
|
|
|
|
|
|
+ var reg = /^(\d{3})\d{4}(\d{4})$/;
|
|
|
|
+ this.setData({
|
|
|
|
+ isLogin: getMobileCache() != '',
|
|
|
|
+ phone: getMobileCache() == ''?'********':getMobileCache().replace(reg, "$1****$2"),
|
|
|
|
+ setPhone: getMobileCache(),
|
|
|
|
+ })
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -93,7 +130,7 @@ Page({
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
-getCouponList: function() {
|
|
|
|
|
|
+ getCouponList: function() {
|
|
Integralinfo.getList({
|
|
Integralinfo.getList({
|
|
channelid: this.data.channelid,
|
|
channelid: this.data.channelid,
|
|
shopid: this.data.shopid,
|
|
shopid: this.data.shopid,
|
|
@@ -115,8 +152,7 @@ couponListView: function(data) {
|
|
v.quantity = 0
|
|
v.quantity = 0
|
|
v.integral = v.price * v.ratio
|
|
v.integral = v.price * v.ratio
|
|
})
|
|
})
|
|
- if (this.mobile != '********') {
|
|
|
|
- let num = this.integralNum > 20000 ? 19999 : this.integralNum
|
|
|
|
|
|
+ let num = this.data.integralNum > 20000 ? 19999 : this.data.integralNum
|
|
const arr = []
|
|
const arr = []
|
|
for (let i = 0; i < data.length; i++) {
|
|
for (let i = 0; i < data.length; i++) {
|
|
data[i].quantity = parseInt(num / data[i].integral)
|
|
data[i].quantity = parseInt(num / data[i].integral)
|
|
@@ -132,7 +168,6 @@ couponListView: function(data) {
|
|
couponList: [...arr, ...data]
|
|
couponList: [...arr, ...data]
|
|
})
|
|
})
|
|
console.log(this.data.couponList)
|
|
console.log(this.data.couponList)
|
|
- }
|
|
|
|
},
|
|
},
|
|
// 点击标识点触发
|
|
// 点击标识点触发
|
|
detailsClick(row) {
|
|
detailsClick(row) {
|
|
@@ -195,5 +230,214 @@ hideModal() {
|
|
animationData: animation.export()
|
|
animationData: animation.export()
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
+
|
|
|
|
+/**授权手机号 */
|
|
|
|
+getPhoneNumber(e) {
|
|
|
|
+ getPhoneNumberSync(e, async () => {
|
|
|
|
+ console.log(e)
|
|
|
|
+ if (getMobileCache() == '') {
|
|
|
|
+ wx.showToast({
|
|
|
|
+ icon:'error',
|
|
|
|
+ title:'先查询移动积分'
|
|
|
|
+ })
|
|
|
|
+ setTimeout(()=>{
|
|
|
|
+ that.data.setPhone = ''
|
|
|
|
+ that.scoreClick()
|
|
|
|
+ wx.hideLoading()
|
|
|
|
+ },500)
|
|
|
|
+ } else {
|
|
|
|
+ var reg = /^(\d{3})\d{4}(\d{4})$/;
|
|
|
|
+ this.setData({
|
|
|
|
+ isLogin: true,
|
|
|
|
+ setPhone: getMobileCache(),
|
|
|
|
+ mobile: getMobileCache(),
|
|
|
|
+ phone: getMobileCache().replace(reg, "$1****$2")
|
|
|
|
+ })
|
|
|
|
+ // console.log(this.data.setPhone)
|
|
|
|
+ // console.log(this.data.mobile)
|
|
|
|
+ // console.log(this.data.phone)
|
|
|
|
+ // this.getphoneClick()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+// 查询积分
|
|
|
|
+scoreClick() {
|
|
|
|
+ this.setData({
|
|
|
|
+ bgStatus: true,
|
|
|
|
+ scorePhone: true,
|
|
|
|
+ })
|
|
|
|
+},
|
|
|
|
+
|
|
|
|
+// 查询积分
|
|
|
|
+getphoneClick() {
|
|
|
|
+ console.log(this.data.setPhone)
|
|
|
|
+ if (!(/^1[3456789]\d{9}$/.test(this.data.setPhone))) {
|
|
|
|
+ wx.showToast({
|
|
|
|
+ title: '填写正确手机号',
|
|
|
|
+ icon: 'error',
|
|
|
|
+ duration: 2000
|
|
|
|
+ });
|
|
|
|
+ } else if (this.data.setPhone != '') {
|
|
|
|
+ // wx.showLoading({
|
|
|
|
+ // title: '加载中'
|
|
|
|
+ // });
|
|
|
|
+ Integralinfo.getBalance({
|
|
|
|
+ mobile: this.data.setPhone,
|
|
|
|
+ callbackUrl: '../integral/integral.wxml',
|
|
|
|
+ fingerprint: '',
|
|
|
|
+ sessionid: '',
|
|
|
|
+ shopid: 2,
|
|
|
|
+ type: 'wx',
|
|
|
|
+ }).then(arr => {
|
|
|
|
+ console.log(arr)
|
|
|
|
+ wx.hideLoading();
|
|
|
|
+ if (arr.code === '0000') {
|
|
|
|
+ this.data.integralNum = arr.data
|
|
|
|
+ var reg = /^(\d{3})\d{4}(\d{4})$/;
|
|
|
|
+ this.data.mobile = this.data.setPhone
|
|
|
|
+ this.data.setPhone = this.data.setPhone.replace(reg, "$1****$2");
|
|
|
|
+ let response = {
|
|
|
|
+ points: arr.data,
|
|
|
|
+ outTokenId: this.data.setPhone + '_out'
|
|
|
|
+ }
|
|
|
|
+ App.globalData.AppShow = response
|
|
|
|
+ this.hideModal()
|
|
|
|
+ this.getCouponList()
|
|
|
|
+ wx.pageScrollTo({
|
|
|
|
+ scrollTop: 0
|
|
|
|
+ });
|
|
|
|
+ let dateNum = Math.round(new Date().getTime() / 1000).toString()
|
|
|
|
+ if (wx.getStorageSync('orderDetails') != '' && this.data.mobile === JSON.parse(wx
|
|
|
|
+ .getStorageSync('orderDetails')).mobile) {
|
|
|
|
+ if (dateNum - JSON.parse(wx.getStorageSync('orderDetails')).date <= 120) {
|
|
|
|
+ const data = JSON.parse(wx.getStorageSync('orderDetails'))
|
|
|
|
+ if (dateNum - data.date < 60) {
|
|
|
|
+ let time = dateNum - data.date
|
|
|
|
+ this.codeName = 60 - time + 's后重新获取'
|
|
|
|
+ this.codeSetInterval(60 - time)
|
|
|
|
+ } else {
|
|
|
|
+ this.codeName = '重新获取验证码'
|
|
|
|
+ }
|
|
|
|
+ this.data.paymentStatus = true
|
|
|
|
+ this.data.paymentBgStatus = true
|
|
|
|
+ this.data.active1code = ''
|
|
|
|
+ this.data.active2code = ''
|
|
|
|
+ this.data.active1obj = data
|
|
|
|
+ if (data.step === 1) {
|
|
|
|
+ this.data.activeNum = 1
|
|
|
|
+ } else if (data.step === 2) {
|
|
|
|
+ this.data.activeNum = 0
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ this.data.loading = true
|
|
|
|
+ this.data.bgStatus = true
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ // #ifdef H5
|
|
|
|
+ window.location.href = arr.message;
|
|
|
|
+ // #endif
|
|
|
|
+
|
|
|
|
+ // #ifdef MP-WEIXIN
|
|
|
|
+ const version = wx.getSystemInfoSync().SDKVersion
|
|
|
|
+
|
|
|
|
+ if (this.compareVersion(version, '2.20.1') >= 0) {
|
|
|
|
+ wx.openEmbeddedMiniProgram({
|
|
|
|
+ appId: arr.data.appId,
|
|
|
|
+ path: arr.data.path,
|
|
|
|
+ extraData: arr.data.extraData,
|
|
|
|
+ success(res) {
|
|
|
|
+ // 打开成功
|
|
|
|
+ },
|
|
|
|
+ fail() {}
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ // 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示
|
|
|
|
+ wx.navigateToMiniProgram({
|
|
|
|
+ appId: arr.data.appId,
|
|
|
|
+ path: arr.data.path,
|
|
|
|
+ extraData: arr.data.extraData,
|
|
|
|
+ success(res) {
|
|
|
|
+ // 打开成功
|
|
|
|
+ },
|
|
|
|
+ fail() {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ // #endif
|
|
|
|
+ this.hideModal()
|
|
|
|
+ this.loading = false
|
|
|
|
+ }, 4000)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+},
|
|
|
|
+
|
|
|
|
+// 商品数量减少按钮
|
|
|
|
+reduceClick(e) {
|
|
|
|
+ console.log(e.currentTarget.dataset.index)
|
|
|
|
+ let index = e.currentTarget.dataset.index
|
|
|
|
+ this.data.couponList[index].quantity--
|
|
|
|
+ this.data.total -= parseInt(this.data.couponList[index].integral)
|
|
|
|
+},
|
|
|
|
+// 商品数量添加按钮
|
|
|
|
+addClick(e) {
|
|
|
|
+ let index = e.currentTarget.dataset.index
|
|
|
|
+ if (this.data.phone !== '********') {
|
|
|
|
+ if (this.data.total + parseInt(this.data.couponList[index].integral) > 20000) {
|
|
|
|
+ wx.showToast({
|
|
|
|
+ title: '单笔限额两万分',
|
|
|
|
+ icon: 'error',
|
|
|
|
+ duration: 2000
|
|
|
|
+ });
|
|
|
|
+ } else if ((this.data.integralNum - this.data.total) >= this.data.couponList[index].integral) {
|
|
|
|
+ this.data.couponList[index].quantity++
|
|
|
|
+ this.data.total += parseInt(this.data.couponList[index].integral)
|
|
|
|
+ } else {
|
|
|
|
+ wx.showToast({
|
|
|
|
+ title: '积分不足',
|
|
|
|
+ icon: 'error',
|
|
|
|
+ duration: 2000
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ wx.showToast({
|
|
|
|
+ title: '先查询移动积分',
|
|
|
|
+ icon: 'error',
|
|
|
|
+ duration: 1000
|
|
|
|
+ });
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ this.scoreClick()
|
|
|
|
+ }, 1000)
|
|
|
|
+ }
|
|
|
|
+},
|
|
|
|
+/** 刷新 */
|
|
|
|
+shuaxinClick() {
|
|
|
|
+ Integralinfo.getBalance({
|
|
|
|
+ mobile: this.data.setPhone,
|
|
|
|
+ callbackUrl: '../integral/integral.wxml',
|
|
|
|
+ fingerprint: '',
|
|
|
|
+ sessionid: '',
|
|
|
|
+ shopid: 2,
|
|
|
|
+ type: 'wx',
|
|
|
|
+ }).then(arr => {
|
|
|
|
+ if (arr.code === '0000') {
|
|
|
|
+ wx.hideLoading();
|
|
|
|
+ wx.showToast({
|
|
|
|
+ title: '查询成功!',
|
|
|
|
+ icon: 'success',
|
|
|
|
+ duration: 1000
|
|
|
|
+ });
|
|
|
|
+ this.data.integralNum = arr.data
|
|
|
|
+ var reg = /^(\d{3})\d{4}(\d{4})$/;
|
|
|
|
+ this.data.setPhone = this.data.mobile
|
|
|
|
+ this.data.phone = this.data.setPhone.replace(reg, "$1****$2");
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+},
|
|
|
|
|
|
})
|
|
})
|