Setting.js 5.02 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
//hospitalDetail.js 医院详情介绍

// 网络请求工具类
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/jianchajilu.png', text: '我的预约', right_text:'',margin:0},
// { icon: '../../source/jianchajilu.png', text: '儿童档案', right_text: '', margin: 10 },
// { icon: '../../source/jianchajilu.png', text: '消息提醒', right_text: '', margin: 0 },
// { icon: '../../source/jianchajilu.png', text: '交易记录', right_text: '', margin: 0 },
// { icon: '../../source/jianchajilu.png', text: '我的收藏', right_text: '', margin: 10 },
{ 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.setData({ userData: getApp().globalData.userInfo})
},
onShow:function(){
var self=this
if (app.globalData.userInfo.status == 1) {
self.setData({
isVip: true
})
} else {
self.setData({
isVip: false
})
}
},
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属性显示图片
console.log('图片',res)
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 = '../feedback/feedback'
break
case 1:
wx.showToast({
title: '清除成功',
})
// url = '../PersonalInfo/PersonalInfo'
break
case 2:
url = '../system_notifacations/system_notifacations'
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', '')
getApp().globalData.token = ''
getApp().globalData.userId = ''
wx.navigateBack({
})
}
},
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 () {
console.log("dsfsrfwqerfwqrfqw")
wx.navigateTo({
url: '../vipService/vipService',
})
}

})