Setting.js 5.62 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
//hospitalDetail.js 医院详情介绍
//聊天控件
let WebIM = wx.WebIM = require("../../utils/WebIM.js").default;
// 网络请求工具类
var networkUtil = require('../../utils/network_util.js')
var api = require('../../utils/apiFile.js')
// var qiniuUploader = require('../../utils/qiniuUploader.js')
// 获取应用实例
var app = getApp()
Page({
data: {
setList: [
{ icon: '../../source/set_dangan.png', text: '信息绑定', right_text: '', margin: 0 },
{ icon: '../../source/feedback_icon.png', text: '用户反馈', right_text: '', margin: 0 },
{ icon: '../../source/clear_cach.png', text: '清除缓存', right_text: '', margin:10} ],
isShowOne: false,
isShowTwo: false,
isShowThree: false,
isVip:false,
userData:''
},
onLoad: function (option) {

this.getUserInfo()
},
onShow:function(){
var self=this
if (app.globalData.userInfo.status == 1 || app.globalData.userInfo.bzstatus==1) {
self.setData({
isVip: true
})
} else {
self.setData({
isVip: false
})
}
},
// 获取用户信息
getUserInfo(userId) {
networkUtil.showLoading()
var self = this
var param = { 'token': app.globalData.token }
if (getApp().globalData.tourist == true) {
param.type = 2
}
networkUtil._get(api.userInfo + app.globalData.currentId, param, function (res) {
console.log('获取用户信息', res)
self.setUserInfo(res.data.data)
}, function (res) {
networkUtil.showErrorToast(res.errormsg)
})
},
// 设置UI 用户信息
setUserInfo(data) {
var self = this
app.globalData.days = data.days
app.globalData.userInfo = data
self.setData({
userData: data,
tourist: getApp().globalData.tourist
})
},
// selectPhoto(){
// var that = this
// wx.showActionSheet({
// itemList: ['手机拍照','本地相册'],
// success: function (res) {
// if (!res.tapIndex) {
// return
// }
// var imgType = 'camera'
// if (res.tapIndex == 1) {
// imgType = 'album'
// }
// wx.chooseImage({
// count: 1, // 默认9
// sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
// sourceType: [imgType], // 可以指定来源是相册还是相机,默认二者都有
// success: function (res) {
// // 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
// that.qiniuToken(res.tempFilePaths[0])
// }
// })
// },
// fail: function (res) {
// console.log(res.errMsg)
// }
// })
// },
clickPage(e){
console.log(e)
var index = e.currentTarget.dataset.index
var url = ''
switch(index){
case 0:
url = '../inforBind/inforBind'
break
case 1:
url = '../feedback/feedback'
break
case 2:
wx.showToast({
title: '清除成功',
})
break
// case 3:
// url = '../PersonalInfo/PersonalInfo'
// break
// case 4:
// url = '../mySaved/mySaved'
// break
// case 5:
// url = '../feedback/feedback'
// break
// case 6:
// break
}
wx.navigateTo({
url: url
})
},
logout(){
var that = this
wx.showActionSheet({
itemList: ['退出当前用户'],
success: function (res) {
if (res.tapIndex == 0) {
wx.setStorageSync('userToken', '')
wx.setStorageSync('userId', '')
wx.setStorageSync('access_token', '')
wx.setStorageSync('hxName', '')
wx.setStorageSync('hxPassWord', '')
getApp().globalData.token = ''
getApp().globalData.userId = ''
wx.navigateBack({})
WebIM.conn.close()
}
},
fail: function (res) {
console.log(res.errMsg)
}
})
},
uploadImg(upToken,imageUrl){
var that = this;
console.log(upToken, imageUrl)
// qiniuUploader.upload(imageUrl, (res) => {
// console.log(res)
// that.setData({
// 'imageURL': res.imageURL,
// });
// }, (error) => {
// console.log('error: ' + error);
// }, {
// uploadURL: 'https://up.qbox.me',
// domain: 'upload.qiniu.com',
// uptokenURL: 'UpTokenURL.com/uptoken',
// })
wx.uploadFile({
url: 'https://up.qbox.me',
filePath: imageUrl,
name: 'file',
formData: {
'key': imageUrl.split('//')[1],
'token': upToken
},
success: function (res) {
var data = JSON.parse(res.data);
},
fail(error) {
console.log(error)
},
complete(res) {
console.log(res)
}
})
},
qiniuToken(imageUrl){
var that = this;
networkUtil._get(api.kApiQiNiuImageToken, {}, function (res) {
if (res.data && res.data.upToken){
that.uploadImg(res.data.upToken, imageUrl)
}
}, function (res) {
networkUtil.showErrorToast(res.errormsg)
})
},
// 成功上传头像后 上传服务器
changeUserInfo(image){
var that = this;
networkUtil._put(api.kApiModifyMyInfo, {}, function (res) {
if (res.data && res.data.upToken) {
that.uploadImg(res.data.upToken, imageUrl)
}
}, function (res) {
networkUtil.showErrorToast(res.errormsg)
})
},
toVip: function () {
wx.navigateTo({
url: '../vipService/vipService',
})
}

})