index.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. // pages/ucenter/index/index.js
  2. var app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. userInfo: {},
  9. isLogin: false
  10. },
  11. tologin(e) {
  12. let url = '/pages/login/phone_login/phone_login';
  13. wx.navigateTo({
  14. url
  15. });
  16. },
  17. toUserCenter(e){
  18. if (this.phoneCheck()) {
  19. let url = '/pages/ucenter/center/center';
  20. wx.navigateTo({
  21. url
  22. });
  23. }
  24. },
  25. logout(e){
  26. if (this.data.isLogin) {
  27. wx.clearStorageSync();
  28. wx.reLaunch({
  29. url: '/pages/index/index',
  30. });
  31. }
  32. },
  33. phoneCall(e){
  34. wx.makePhoneCall({
  35. phoneNumber: getApp().globalData.helpPhoneNum
  36. });
  37. },
  38. phoneCheck(){
  39. if (this.data.userInfo.bindingPhone==0 && !this.data.userInfo.flag) {
  40. wx.showModal({
  41. title: '提示',
  42. content: '当前账户未绑定手机号,请您进行手机号绑定操作',
  43. showCancel:false,
  44. confirmText: '去绑定',
  45. confirmColor:'#00AADD',
  46. success: function (res1) {
  47. let url = `/pages/bindPhone/bindPhone`;
  48. wx.navigateTo({
  49. url
  50. });
  51. }
  52. })
  53. return false;
  54. }else{
  55. return true;
  56. }
  57. },
  58. /**
  59. * 生命周期函数--监听页面加载
  60. */
  61. onLoad: function(options) {
  62. //wx.setNavigationBarTitle({
  63. // title: '个人中心'
  64. //})
  65. },
  66. /**
  67. * 生命周期函数--监听页面初次渲染完成
  68. */
  69. onReady: function() {
  70. },
  71. /**
  72. * 生命周期函数--监听页面显示
  73. */
  74. onShow: function() {
  75. let userInfo = wx.getStorageSync('userInfo');
  76. let isLogin = wx.getStorageSync('isLogin');
  77. // console.log(userInfo.flag);
  78. // 页面显示
  79. if (userInfo && isLogin) {
  80. //userInfo.flag = true;
  81. this.setData({
  82. userInfo: userInfo,
  83. isLogin: isLogin
  84. });
  85. } else {
  86. //未登录信息
  87. this.setData({
  88. userInfo: {},
  89. isLogin: false
  90. });
  91. }
  92. },
  93. /**
  94. * 生命周期函数--监听页面隐藏
  95. */
  96. onHide: function() {
  97. },
  98. /**
  99. * 生命周期函数--监听页面卸载
  100. */
  101. onUnload: function() {
  102. },
  103. /**
  104. * 页面相关事件处理函数--监听用户下拉动作
  105. */
  106. onPullDownRefresh: function() {
  107. },
  108. /**
  109. * 页面上拉触底事件的处理函数
  110. */
  111. onReachBottom: function() {
  112. },
  113. /**
  114. * 用户点击右上角分享
  115. */
  116. onShareAppMessage: function() {
  117. },
  118. goCharginglog(e) {
  119. if (!this.data.isLogin) {
  120. let url = `/pages/login/phone_login/phone_login`;
  121. wx.navigateTo({
  122. url
  123. });
  124. return;
  125. }
  126. let url = '/pages/ucenter/charginglog/charginglog'
  127. wx.navigateTo({
  128. url
  129. });
  130. },
  131. goChargemoneylog(e) {
  132. if (!this.data.isLogin) {
  133. let url = `/pages/login/phone_login/phone_login`;
  134. wx.navigateTo({
  135. url
  136. });
  137. return;
  138. }
  139. let url = '/pages/ucenter/chargemoneylog/chargemoneylog'
  140. wx.navigateTo({
  141. url
  142. });
  143. },
  144. goPurse(e) {
  145. if (!this.data.isLogin) {
  146. let url = `/pages/login/phone_login/phone_login`;
  147. wx.navigateTo({
  148. url
  149. });
  150. return;
  151. }
  152. let url = '/pages/ucenter/purse/purse'
  153. wx.navigateTo({
  154. url
  155. });
  156. },
  157. goMyChargeSation(e) {
  158. let url = '/pages/ucenter/mychargestation/mychargestation'
  159. wx.navigateTo({
  160. url
  161. });
  162. },
  163. goChargpileMonitor(e) {
  164. let url = '/pages/ucenter/chargpilemonitor/chargpilemonitor'
  165. wx.navigateTo({
  166. url
  167. });
  168. },
  169. goMyWorksheet(e) {
  170. let url = '/pages/ucenter/myworksheet/myworksheet'
  171. wx.navigateTo({
  172. url
  173. });
  174. },
  175. goAccountSecrity(e){
  176. if (!this.data.isLogin) {
  177. let url = `/pages/login/phone_login/phone_login`;
  178. wx.navigateTo({
  179. url
  180. });
  181. return;
  182. }
  183. if (this.phoneCheck()) {
  184. let url = '/pages/ucenter/accountsecurity/index/index'
  185. wx.navigateTo({
  186. url
  187. });
  188. }
  189. },
  190. goHelp(){
  191. // wx.downloadFile({
  192. // //url: getApp().globalData.postHeadAgreement + '/restapi/wechat/updateUser',//要预览的PDF的地址
  193. // url: 'http://localhost:8080/aiconfig/index/downloadTest',//要预览的PDF的地址
  194. // success: function (res) {
  195. // console.log(res);
  196. // if (res.statusCode === 200) { //成功
  197. // var Path = res.tempFilePath //返回的文件临时地址,用于后面打开本地预览所用
  198. // wx.openDocument({
  199. // filePath: Path, //要打开的文件路径
  200. // success: function (res) {
  201. // console.log('打开PDF成功');
  202. // }
  203. // });
  204. // }
  205. // },
  206. // fail: function (res) {
  207. // console.log(res); //失败
  208. // }
  209. // });
  210. let url = '/pages/ucenter/help/help'
  211. wx.navigateTo({
  212. url
  213. });
  214. },
  215. goNotice(){
  216. if (!this.data.isLogin) {
  217. let url = `/pages/login/phone_login/phone_login`;
  218. wx.navigateTo({
  219. url
  220. });
  221. return;
  222. }
  223. let url = '/pages/ucenter/notice/notice'
  224. wx.navigateTo({
  225. url
  226. });
  227. },
  228. toindex(e) {
  229. let url = '/pages/index/index';
  230. // wx.reLaunch({
  231. // url
  232. // });
  233. wx.navigateBack();
  234. },
  235. /*,
  236. goLogin: function() {
  237. wx.navigateTo({
  238. url: '/pages/auth/tologin/tologin?from=ucenter',
  239. })
  240. },
  241. callService: function () {
  242. wx.makePhoneCall({
  243. phoneNumber: '17621230884'
  244. })
  245. },
  246. afterSale: function () {
  247. wx.showModal({
  248. title: '提示',
  249. content: '请在官网或APP中申请售后',
  250. showCancel: false,
  251. confirmColor: '#b4282d',
  252. success: function (res) {
  253. if (res.confirm) {
  254. console.log('用户点击确定')
  255. } else if (res.cancel) {
  256. console.log('用户点击取消')
  257. }
  258. }
  259. })
  260. },
  261. toLogin: function () {
  262. wx.navigateTo({
  263. url: '/pages/auth/tologin/tologin',
  264. })
  265. },
  266. toOrder: function () {
  267. if (this.data.isLogin) {
  268. wx.navigateTo({
  269. url: '/pages/ucenter/order/order',
  270. })
  271. } else {
  272. this.toLogin()
  273. }
  274. },
  275. toCoupon: function () {
  276. if (this.data.isLogin) {
  277. wx.navigateTo({
  278. url: '/pages/ucenter/coupon/coupon',
  279. })
  280. } else {
  281. this.toLogin()
  282. }
  283. },
  284. toAddress: function () {
  285. if (this.data.isLogin) {
  286. wx.navigateTo({
  287. url: '/pages/ucenter/address/address',
  288. })
  289. } else {
  290. this.toLogin()
  291. }
  292. }*/
  293. })