|
@@ -1,4 +1,5 @@
|
|
|
// pages/welfareMall/personal/personal.js
|
|
|
+import WelfareMall from '../../../api/welfareMall'
|
|
|
import {getMobileCache, getPhoneNumber as getPhoneNumberSync} from '../../../utils/user'
|
|
|
Page({
|
|
|
|
|
@@ -8,29 +9,55 @@ Page({
|
|
|
data: {
|
|
|
isLogin: false,
|
|
|
mobileTop: 'TONY WU',
|
|
|
-
|
|
|
+ countNum: 0,
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
- onLoad: function (options) {
|
|
|
+ onLoad: async function (options) {
|
|
|
this.setData({
|
|
|
isLogin: getMobileCache() != '',
|
|
|
mobileTop: getMobileCache(),
|
|
|
- })
|
|
|
+ })
|
|
|
+
|
|
|
+ if(this.data.isLogin){
|
|
|
+ let nums = await this.getCountNum();
|
|
|
+ this.setData({
|
|
|
+ countNum: nums,
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
},
|
|
|
|
|
|
+ getCountNum: async function(){
|
|
|
+ /**
|
|
|
+ * 福利社
|
|
|
+ */
|
|
|
+ let resBuy = await WelfareMall.getUserBuyCouponNum({
|
|
|
+ mobile: getMobileCache(),
|
|
|
+ });
|
|
|
+ let resAward = await WelfareMall.getUserAwardCouponNum({
|
|
|
+ mobile: getMobileCache(),
|
|
|
+ });
|
|
|
+ let resDraw = await WelfareMall.getUserDrawCouponNum({
|
|
|
+ mobile: getMobileCache(),
|
|
|
+ });
|
|
|
+ let nums = Number(resBuy.data.notUseNum)+Number(resAward.data.notUseNum)+Number(resDraw.data.notUseNum)
|
|
|
+ return nums;
|
|
|
+ },
|
|
|
+
|
|
|
// 授权手机号
|
|
|
getPhoneNumber(e) {
|
|
|
- getPhoneNumberSync(e, _ => {
|
|
|
+ getPhoneNumberSync(e, async () => {
|
|
|
+ let nums = await this.getCountNum();
|
|
|
this.setData({
|
|
|
isLogin: true,
|
|
|
mobileTop: getMobileCache(),
|
|
|
- })
|
|
|
+ countNum: nums,
|
|
|
+ })
|
|
|
})
|
|
|
-},
|
|
|
+ },
|
|
|
|
|
|
toHistorical(e) {
|
|
|
const url = "../historical/historical?id=" + e.currentTarget.dataset.id
|