|
@@ -1,3 +1,7 @@
|
|
|
+import {BASE_URL} from '../../utils/request';
|
|
|
+import { uploadImage } from '../../utils/upload.js';
|
|
|
+import { MAKE_PHONE_CALL } from '../../utils/util.js';
|
|
|
+import {userModify} from '../../api/user';
|
|
|
const app = getApp();
|
|
|
Page({
|
|
|
data: {
|
|
@@ -9,47 +13,32 @@ Page({
|
|
|
{ icon: '/static/image/me-5.png', title: '设置' },
|
|
|
{ icon: '/static/image/me-6.png', title: '联系客服' }
|
|
|
],
|
|
|
- userInfo: {}
|
|
|
+ userInfo: {},
|
|
|
+ programConfig:{},
|
|
|
+ url:BASE_URL,
|
|
|
+ showAgreementModal:false
|
|
|
},
|
|
|
goPage(e){
|
|
|
const index = e.currentTarget.dataset.index;
|
|
|
- if(index == 0){
|
|
|
- wx.navigateTo({
|
|
|
- url: `/pages/rules/rules?type=${index}`
|
|
|
- })
|
|
|
- }else if(index == 1){
|
|
|
- wx.navigateTo({
|
|
|
- url: `/pages/rules/rules?type=${index}`
|
|
|
- })
|
|
|
- }else if(index == 4){
|
|
|
- wx.navigateTo({
|
|
|
- url: `/pages/setting/setting`
|
|
|
- })
|
|
|
- }else if(index == 2){
|
|
|
- wx.navigateTo({
|
|
|
- url: `/pages/registrationRecords/registrationRecords`
|
|
|
- })
|
|
|
- }else if(index == 3){
|
|
|
- wx.navigateTo({
|
|
|
- url: `/pages/coupon/coupon`
|
|
|
- })
|
|
|
+ const pageMap = {
|
|
|
+ 0: `/pages/rules/rules?type=${index}`,
|
|
|
+ 1: `/pages/rules/rules?type=${index}`,
|
|
|
+ 2: `/pages/registrationRecords/registrationRecords`,
|
|
|
+ 3: `/pages/coupon/coupon`,
|
|
|
+ 4: `/pages/setting/setting`
|
|
|
+ };
|
|
|
+ if (pageMap[index]) {
|
|
|
+ wx.navigateTo({ url: pageMap[index] });
|
|
|
+ } else if (index === 5) {
|
|
|
+ this.setData({ showAgreementModal: true });
|
|
|
}
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
this.setData({
|
|
|
- userInfo: app.globalData.userInfo
|
|
|
+ userInfo: app.globalData.userInfo,
|
|
|
+ programConfig:app.globalData.programConfig
|
|
|
});
|
|
|
},
|
|
|
- /**
|
|
|
- * 生命周期函数--监听页面初次渲染完成
|
|
|
- */
|
|
|
- onReady() {
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 生命周期函数--监听页面显示
|
|
|
- */
|
|
|
onShow() {
|
|
|
if (typeof this.getTabBar === 'function' && this.getTabBar()) {
|
|
|
this.getTabBar().setData({ selected: 2 })
|
|
@@ -58,6 +47,36 @@ Page({
|
|
|
userInfo: app.globalData.userInfo
|
|
|
});
|
|
|
},
|
|
|
+ // 头像
|
|
|
+ async onChooseAvatar(e) {
|
|
|
+ const { avatarUrl } = e.detail;
|
|
|
+ // 上传到服务器
|
|
|
+ const res = await uploadImage(avatarUrl);
|
|
|
+ this.setData({
|
|
|
+ "userInfo.avatar":avatarUrl
|
|
|
+ });
|
|
|
+ this.onSave(res.path);
|
|
|
+ },
|
|
|
+ async onSave(pathUrl){
|
|
|
+ const res = await userModify({avatar:pathUrl});
|
|
|
+ if(res.code == 200){
|
|
|
+ wx.showToast({
|
|
|
+ title: '更新成功',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ app.globalData.userInfo = res.data;
|
|
|
+ }else{
|
|
|
+ wx.showToast({
|
|
|
+ title: res.message || '更新失败',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onPhone(){
|
|
|
+ MAKE_PHONE_CALL('15527606226');
|
|
|
+ },
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面隐藏
|