usercenter.vue
11.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
<template>
<view class="content">
<view class="usertop commnonpadding">
<view class="userhsang flexone">
<view class="usershangleft">
<image :src="avatar==''?'../../static/headtou.png':avatar" mode=""></image>
</view>
<view class="usershangright">
<view class="righttop flexone">
<view class="vip flexthree" v-if="userinfo.is_card==1||userinfo.is_vip==1||userinfo.is_company_vip==1">
<view class="vipimg" v-if="userinfo.is_card==1">
<image src="../../static/huiyuan.png" mode=""></image>
</view>
<view class="vipnum" v-if="userinfo.is_vip==1">{{userinfo.level.name1}}</view>
<view class="vipnum" v-if="userinfo.is_company_vip==1">{{userinfo.level.name2}}</view>
</view>
<view class="usernicheng" v-if="nickname==''">暂无昵称</view>
<view class="usernicheng" v-else>{{nickname}}</view>
</view>
<view class="rightbot" v-if="userinfo.vip_pasttime!=null&&sel==1">会员到期时间:{{userinfo.vip_pasttime}}</view>
</view>
</view>
<view class="viprank flextwo" v-if="sel==1">
<view class="viprankleft" v-if="userinfo.percentage!=100">{{userinfo.level.name1}}</view>
<view class="vipmiddle">
<view class="vipmiddlenei boxsizing" :style="{width:userinfo.percentage+'%'}">
<view class="remain" v-if="userinfo.percentage!=100">还需{{userinfo.residue_exp}}经验升级到{{userinfo.next_level.name2}}</view>
</view>
</view>
<view class="viprankleft" v-if="userinfo.percentage==100">{{userinfo.level.name1}}</view>
<view class="viprankleft viprankleftk" v-if="userinfo.percentage!=100">{{userinfo.next_level.name1}}</view>
</view>
<view class="viprank flextwo" v-else>
<view class="viprankleft" v-if="userinfo.percentage!=100">{{userinfo.level.name2}}</view>
<view class="vipmiddle">
<view class="vipmiddlenei boxsizing" :style="{width:userinfo.percentage+'%'}">
<view class="remain" v-if="userinfo.percentage!=100">还需{{userinfo.residue_exp}}经验升级到{{userinfo.next_level.name2}}</view>
</view>
</view>
<view class="viprankleft viprankleftk" v-if="userinfo.percentage!=100">{{userinfo.next_level.name2}}</view>
<view class="viprankleft viprankleftk" v-if="userinfo.percentage==100">{{userinfo.level.name2}}</view>
</view>
</view>
<view class="tapnav flextwo huiyuannav boxsizing" v-if="userinfo.is_company_vip==2">
<view class="tapnavitem" :class="sel==1?'huiyuanactive':''" @click="selhui" :data-id="1">个人会员</view>
<view class="tapnavitem" :class="sel==2?'huiyuanactive':''" @click="selhui" :data-id="2">企业会员</view>
</view>
<view class="huiyuanimg" v-if="sel==1&&userinfo.is_company_vip==2">
<image src="../../static/vipbg.png" mode=""></image>
<view class="huiyuannei flextwo">
<view class='huiyuanneileft flexone'>
<view class="zuanshi">
<image src="../../static/zuanshi.png" mode=""></image>
</view>
<view class="huiprice">
<view class="huimoney">¥1000</view>
<view class="huimonth">12个月</view>
</view>
</view>
<view class="huiyuanright" @click="openhuiyuan">{{userinfo.is_vip==1?'续费':'立即开通'}}</view>
</view>
</view>
<view class="huiyuanimg" v-if="sel==2&&userinfo.is_company_vip==1">
<image src="../../static/vipbg.png" mode=""></image>
<view class="huiyuannei flextwo ">
<view class='huiyuanneileft flexone behuiyuanbox'>
<view class="zuanshi">
<image src="../../static/zuanshi.png" mode=""></image>
</view>
<view class="behuiyuan">您已成为企业会员</view>
</view>
</view>
</view>
<view class="tequan boxsizing">会员特权</view>
<view class="commnonpadding huiyuanbox">
<view class="huiyuanitem boxsizing flexone">
<view class="huiyuanitemleft">
<image src="../../static/jifen.png" mode=""></image>
</view>
<view class="huiyuanitemname">购买商品得积分</view>
</view>
<view class="huiyuanitem boxsizing flexone">
<view class="huiyuanitemleft">
<image src="../../static/zhekou.png" mode=""></image>
</view>
<view class="huiyuanitemname">店铺消费享折扣</view>
</view>
</view>
<view v-if="sel==2&&userinfo.is_company_vip==2">
<view class="huiyuanbot boxsizing" @click="behuiyuan">
<view class="behuiyuanbtn">成为企业会员</view>
</view>
<!-- <view class="huiyuanbot boxsizing" >
<view class="behuiyuanbtn">您已经成为企业会员</view>
</view> -->
</view>
<!-- 购买弹层 -->
<view class="register" @click="hidebuy" v-if="buyshow">
<view class="buywrap boxsizing" @click.stop="hidebuyk">
<view class="buyname">总额</view>
<view class="buymoney">1000</view>
<view class='buybox'>
<view class="buyitem boxsizing flextwo" @click.stop="paytype" :data-id="1">
<view class="buyitemleft flexone">
<view class="buyleftimg">
<image src="../../static/weixin.png" mode=""></image>
</view>
<view class="buyitemname">微信支付</view>
</view>
<view class="selimg">
<image src="../../static/selright.png" mode="" v-if="pay_type==1"></image>
<image src="../../static/meisel.png" mode="" v-else></image>
</view>
</view>
<view class="buyitem boxsizing flextwo" @click.stop="paytype" :data-id="2">
<view class="buyitemleft flexone">
<view class="buyleftimg">
<image src="../../static/zhifubao.png" mode=""></image>
</view>
<view class="buyitemname">支付宝</view>
</view>
<view class="selimg">
<image src="../../static/selright.png" mode="" v-if="pay_type==2"></image>
<image src="../../static/meisel.png" mode="" v-else></image>
</view>
</view>
<view class="buyitem boxsizing flextwo" @click.stop="paytype" :data-id="3">
<view class="buyitemleft flexone">
<view class="buyleftimg">
<image src="../../static/yue.png" mode=""></image>
</view>
<view class="buyitemname">余额支付(余额{{yumoney}})</view>
</view>
<view class="selimg">
<image src="../../static/selright.png" mode="" v-if="pay_type==3"></image>
<image src="../../static/meisel.png" mode="" v-else></image>
</view>
</view>
<view class="buyitem boxsizing flextwo" @click.stop="paytype" :data-id="4">
<view class="buyitemleft flexone">
<view class="buyleftimg">
<image src="../../static/baitiao.png" mode=""></image>
</view>
<view class="buyitemname" v-if="is_borrow==1">赊吧支付 <text style="margin-left:5rpx">赊吧剩余额度({{borrow_money}})</text> <text style="margin-left:5rpx">总额度({{borrow_money_limit}})</text></view>
<!-- <view class="buyitemname" v-else>赊吧支付 <text style="margin-left:5rpx" @click="applayshen">申请开通</text></view> -->
<view v-else>
<view class="buyitemname" v-if="borrow_apply_status==0">赊吧支付 <text style="margin-left:5rpx" @click="applayshen">申请开通</text></view>
<view class="buyitemname" v-if="borrow_apply_status==1">赊吧支付 <text style="margin-left:5rpx" >审核中</text></view>
<view class="buyitemname" v-if="borrow_apply_status==2">赊吧支付 <text style="margin-left:5rpx" @click="applayshen">赊吧禁用,继续申请开通赊吧</text></view>
<view class="buyitemname" v-if="borrow_apply_status==3">赊吧支付 <text style="margin-left:5rpx" @click="applayshen">审核没通过,继续申请开通赊吧</text></view>
</view>
</view>
<view class="selimg">
<image src="../../static/selright.png" mode="" v-if="pay_type==4"></image>
<image src="../../static/meisel.png" mode="" v-else></image>
</view>
</view>
</view>
<view class="buybtn" @click="paynow">确认支付(¥1000.00)</view>
</view>
</view>
</view>
</template>
<script>
import app from "../../App.vue";
export default {
data() {
return {
sel: 1,
buyshow: false,
userinfo: '',
nickname: '',
avatar: '',
pay_type: '',
order_id: '',
is_borrow:'',
yumoney:'',
borrow_money_limit:'',
borrow_money:'',
borrow_apply_status:''
}
},
onLoad() {
this.getuserinfo()
},
methods: {
hidebuy() {
this.buyshow = false
},
hidebuyk() {
},
applayshen(){
uni.navigateTo({
url:'/pages/usercenter/shenqing'
})
},
// 选择支付方式
paytype(e) {
this.pay_type = e.currentTarget.dataset.id
},
paynow() {
let that = this;
if (that.pay_type == '') {
uni.showToast({
title: "请选择支付方式",
icon: "none"
})
return false
}
var url = 'member/create_order';
var params = {
pay_type: that.pay_type
}
console.log('7766554', params)
app.post(url, params).then((res) => {
console.log(res);
that.order_id = res.data.data.order_vip_id;
that.paymoney();
}).catch((err) => {
})
},
// 支付接口
paymoney() {
let that = this;
var url = 'member/pay';
var params = {
order_vip_id: that.order_id
}
console.log(params)
app.post(url, params, "post").then((res) => {
console.log(res)
if (that.pay_type == 2) {
// 支付宝支付
uni.requestPayment({
provider: 'alipay',
orderInfo: res.data.data.result,
success(r) {
console.log(r)
}
})
} else if (that.pay_type == 1) {
let result=res.data.data.result;
uni.requestPayment({
provider: 'wxpay',
orderInfo: JSON.stringify(result), //微信、支付宝订单数据
success: function(res) {
console.log('success:' + JSON.stringify(res));
if (res.errMsg == 'requestPayment:ok') {
uni.showToast({
title: '支付成功',
icon: 'none'
})
}
},
fail: function(err) {
console.log('fail:' + JSON.stringify(err));
}
});
} else {
uni.showToast({
title: '支付成功',
icon: 'none'
})
that.buyshow = false;
that.getuserinfo();
}
// uni.showToast({
// title:'支付成功',
// icon:'none'
// })
// setTimeout(function(){
// uni.navigateTo({
// url:'/pages/usercenter/myOrder'
// })
// },1500)
}).catch((err) => {
console.log(err)
uni.showToast({
title: err.msg,
icon: 'none'
})
})
},
// 获取用户信息
getuserinfo() {
let that = this;
var url = 'member/index';
var params = {}
console.log('7766554', params)
app.post(url, params).then((res) => {
console.log(res);
that.userinfo = res.data.data;
that.nickname = res.data.data.nickname;
that.avatar = res.data.data.avatar;
that.yumoney=res.data.data.money;
that.is_borrow=res.data.data.is_borrow;
that.borrow_money_limit=res.data.data.borrow_money_limit;
that.borrow_money=res.data.data.borrow_money;
that.borrow_apply_status=res.data.data.borrow_apply_status
}).catch((err) => {
})
},
selhui(e) {
this.sel = e.currentTarget.dataset.id;
},
behuiyuan() {
uni.navigateTo({
url: './companyshenhe'
})
},
openhuiyuan() {
this.buyshow = true
},
}
}
</script>
<style>
@import url('../../base/usercenter');
page {
background: #F9F9F9;
}
.viprankleft {
width: 100rpx;
}
.viprankleftk {
margin-left: 25rpx;
}
.vipmiddlenei {
position: relative;
}
.remain {
width: 500rpx;
position: absolute;
left: 0;
bottom: 0;
padding-left: 10rpx;
box-sizing: border-box;
}
</style>