|
|
@@ -94,7 +94,19 @@ Page({
|
|
|
if (e.currentTarget.dataset.name != 'toShare') {
|
|
|
switch (e.currentTarget.dataset.name) {
|
|
|
case 'toPower':
|
|
|
- this.getPowerItem()
|
|
|
+ this.getPowerItem().then(res => {
|
|
|
+ const data = res.data.data
|
|
|
+ if (data) {
|
|
|
+ const that = this
|
|
|
+ const endDate = data.endDate
|
|
|
+ const nowTime = data.nowTime
|
|
|
+ const time = that.calculateTimeDifference(new Date(nowTime), new Date(endDate))
|
|
|
+ that.setData({
|
|
|
+ time: time,
|
|
|
+ couponSendItem: data
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
break;
|
|
|
case 'toRegister':
|
|
|
// this.getRegisterItem()
|
|
|
@@ -114,19 +126,7 @@ Page({
|
|
|
sendUser: app.globalData.user.userId,
|
|
|
}
|
|
|
let service = app.globalData['couponSendService']
|
|
|
- this.excute(service, 'get_item', params).then(res => {
|
|
|
- const data = res.data.data
|
|
|
- if (data) {
|
|
|
- const that = this
|
|
|
- const endDate = data.endDate
|
|
|
- const nowTime = data.nowTime
|
|
|
- const time = that.calculateTimeDifference(new Date(nowTime), new Date(endDate))
|
|
|
- that.setData({
|
|
|
- time: time,
|
|
|
- couponSendItem: data
|
|
|
- })
|
|
|
- }
|
|
|
- });
|
|
|
+ return this.excute(service, 'get_item', params)
|
|
|
},
|
|
|
/**
|
|
|
* @desc : 倒计时事件
|
|
|
@@ -164,6 +164,7 @@ Page({
|
|
|
this.setData({
|
|
|
integralTacticItem: res.data.data.list[0],
|
|
|
})
|
|
|
+ this.getShareNumber()
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
@@ -223,28 +224,12 @@ Page({
|
|
|
let service = app.globalData['couponUseService']
|
|
|
this.excute(service, service.countByCond, params).then(res => {
|
|
|
this.setData({
|
|
|
- couponNumber: res.data
|
|
|
+ couponNumber: res.data.data
|
|
|
})
|
|
|
});
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
- * @desc : 优惠券
|
|
|
- * @author : 刘尧
|
|
|
- * @date : 2024/7/25 14:32
|
|
|
- */
|
|
|
- getCouponCount() {
|
|
|
- let params = {}
|
|
|
- let service = app.globalData['couponService']
|
|
|
- this.excute(service, '10002024-0718-0000-0000-000005c0a01e', params).then(res => {
|
|
|
- console.log(res.data);
|
|
|
- if (res.data.code == Constants.SUCESS_CODE) {
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
* @desc : 点击立即助力按钮调后台服务插入优惠劵发出数据
|
|
|
* @author : 刘尧
|
|
|
* @date : 2024/7/25 14:32
|
|
|
@@ -259,19 +244,7 @@ Page({
|
|
|
flgValid: true
|
|
|
}
|
|
|
let service = app.globalData['couponSendService']
|
|
|
- this.excute(service, service.insert, params).then(res => {
|
|
|
- if (res.data.code == Constants.SUCESS_CODE) {
|
|
|
- const that = this
|
|
|
- const data = res.data.data
|
|
|
- const endDate = data.endDate
|
|
|
- const nowTime = data.nowTime
|
|
|
- const time = that.calculateTimeDifference(new Date(nowTime), new Date(endDate))
|
|
|
- that.setData({
|
|
|
- time: time,
|
|
|
- couponSendItem: data
|
|
|
- })
|
|
|
- }
|
|
|
- });
|
|
|
+ return this.excute(service, service.insert, params)
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
@@ -290,19 +263,64 @@ Page({
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
+ * @desc : 分享调用
|
|
|
+ * @author : 刘尧
|
|
|
+ * @date : 2024/7/30 15:40
|
|
|
+ */
|
|
|
+ shareIntegral(){
|
|
|
+ let service = app.globalData['integralShareService']
|
|
|
+ const params = {
|
|
|
+ cpId: app.globalData.company.cpId,
|
|
|
+ tacticId: this.data.integralTacticItem.tacticId,
|
|
|
+ flgValid: true,
|
|
|
+ integralType: Constants.integralType.share,
|
|
|
+ userId: app.globalData.user.userId,
|
|
|
+ }
|
|
|
+ return this.excute(service, service.insert, params)
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 获取用户剩余分享次数
|
|
|
+ * @author : 刘尧
|
|
|
+ * @date : 2024/7/30 15:40
|
|
|
+ */
|
|
|
+ getShareNumber(){
|
|
|
+ let service = app.globalData['integralShareService']
|
|
|
+ const params = {
|
|
|
+ cpId: app.globalData.company.cpId,
|
|
|
+ tacticId: this.data.integralTacticItem.tacticId,
|
|
|
+ flgValid: true,
|
|
|
+ integralType: Constants.integralType.share,
|
|
|
+ userId: app.globalData.user.userId,
|
|
|
+ }
|
|
|
+ this.excute(service, 'select_share_number', params).then(res => {
|
|
|
+ console.log('getShareNumber', res.data.data);
|
|
|
+ const integralTacticItem = this.data.integralTacticItem
|
|
|
+ integralTacticItem.shareDayNum = integralTacticItem.shareDayNum - res.data.data
|
|
|
+ this.setData({
|
|
|
+ integralTacticItem: integralTacticItem
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /**
|
|
|
* 用户点击右上角分享
|
|
|
*/
|
|
|
- onShareAppMessage(e) {
|
|
|
+ onShareAppMessage: async function(e) {
|
|
|
const url = this.data.imageUrl + 'share-background.png'
|
|
|
this.setData({
|
|
|
cilckViewId: e.target.dataset.detail
|
|
|
})
|
|
|
if (e.target.dataset.detail === "toShare") {
|
|
|
- return {
|
|
|
- title: '分享好友获取云币',
|
|
|
- desc: '分享不停歇',
|
|
|
- path: '/pages/welcome/welcome',
|
|
|
- imageUrl: url
|
|
|
+ const res = await this.shareIntegral()
|
|
|
+ console.log('shareIntegral', res);
|
|
|
+ if (res.data.code == Constants.SUCESS_CODE) {
|
|
|
+ this.getShareNumber()
|
|
|
+ return {
|
|
|
+ title: '分享好友获取云币',
|
|
|
+ desc: '分享不停歇',
|
|
|
+ path: '/pages/welcome/welcome',
|
|
|
+ imageUrl: url
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if (e.target.dataset.detail === "toRegister") {
|
|
|
@@ -315,13 +333,37 @@ Page({
|
|
|
}
|
|
|
if (e.target.dataset.detail === "toPower") {
|
|
|
const couponDesc = this.data.couponItem.couponDesc
|
|
|
- console.log('discount', couponDesc);
|
|
|
- this.insertNewPowerItem()
|
|
|
+ let item = await this.getPowerItem()
|
|
|
+ item = item.data.data
|
|
|
+ if (item) {
|
|
|
+ const that = this
|
|
|
+ const endDate = item.endDate
|
|
|
+ const nowTime = item.nowTime
|
|
|
+ const time = that.calculateTimeDifference(new Date(nowTime), new Date(endDate))
|
|
|
+ that.setData({
|
|
|
+ time: time,
|
|
|
+ couponSendItem: item
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if(!this.data.couponSendItem){
|
|
|
+ const that = this
|
|
|
+ const res = await this.insertNewPowerItem()
|
|
|
+ if (res.data.code == Constants.SUCESS_CODE) {
|
|
|
+ const data = res.data.data
|
|
|
+ const endDate = data.endDate
|
|
|
+ const nowTime = data.nowTime
|
|
|
+ const time = that.calculateTimeDifference(new Date(nowTime), new Date(endDate))
|
|
|
+ that.setData({
|
|
|
+ time: time,
|
|
|
+ couponSendItem: data
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
const that = this
|
|
|
return {
|
|
|
title: couponDesc,
|
|
|
desc: '助力拿福利',
|
|
|
- path: '/package-basic-data/pages/share-power/share-power?cpId=' + app.globalData.company.cpId + '&couponId=' + that.data.couponItem.couponId,
|
|
|
+ path: '/package-basic-data/pages/share-power/share-power?cpId=' + app.globalData.company.cpId + '&couponId=' + that.data.couponItem.couponId + '&sendId=' + that.data.couponSendItem.sendId + '&discount=' + that.data.couponItem.discount,
|
|
|
imageUrl: url
|
|
|
}
|
|
|
}
|