index.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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. goAgreement(){
  191. let url = '/pages/agreement/list'
  192. wx.navigateTo({
  193. url
  194. });
  195. },
  196. goHelp(){
  197. // wx.downloadFile({
  198. // //url: getApp().globalData.postHeadAgreement + '/restapi/wechat/updateUser',//要预览的PDF的地址
  199. // url: 'http://localhost:8080/aiconfig/index/downloadTest',//要预览的PDF的地址
  200. // success: function (res) {
  201. // console.log(res);
  202. // if (res.statusCode === 200) { //成功
  203. // var Path = res.tempFilePath //返回的文件临时地址,用于后面打开本地预览所用
  204. // wx.openDocument({
  205. // filePath: Path, //要打开的文件路径
  206. // success: function (res) {
  207. // console.log('打开PDF成功');
  208. // }
  209. // });
  210. // }
  211. // },
  212. // fail: function (res) {
  213. // console.log(res); //失败
  214. // }
  215. // });
  216. let url = '/pages/ucenter/help/help'
  217. wx.navigateTo({
  218. url
  219. });
  220. },
  221. goNotice(){
  222. if (!this.data.isLogin) {
  223. let url = `/pages/login/phone_login/phone_login`;
  224. wx.navigateTo({
  225. url
  226. });
  227. return;
  228. }
  229. let url = '/pages/ucenter/notice/notice'
  230. wx.navigateTo({
  231. url
  232. });
  233. },
  234. toindex(e) {
  235. let url = '/pages/index/index';
  236. // wx.reLaunch({
  237. // url
  238. // });
  239. wx.navigateBack();
  240. },
  241. /*,
  242. goLogin: function() {
  243. wx.navigateTo({
  244. url: '/pages/auth/tologin/tologin?from=ucenter',
  245. })
  246. },
  247. callService: function () {
  248. wx.makePhoneCall({
  249. phoneNumber: '17621230884'
  250. })
  251. },
  252. afterSale: function () {
  253. wx.showModal({
  254. title: '提示',
  255. content: '请在官网或APP中申请售后',
  256. showCancel: false,
  257. confirmColor: '#b4282d',
  258. success: function (res) {
  259. if (res.confirm) {
  260. console.log('用户点击确定')
  261. } else if (res.cancel) {
  262. console.log('用户点击取消')
  263. }
  264. }
  265. })
  266. },
  267. toLogin: function () {
  268. wx.navigateTo({
  269. url: '/pages/auth/tologin/tologin',
  270. })
  271. },
  272. toOrder: function () {
  273. if (this.data.isLogin) {
  274. wx.navigateTo({
  275. url: '/pages/ucenter/order/order',
  276. })
  277. } else {
  278. this.toLogin()
  279. }
  280. },
  281. toCoupon: function () {
  282. if (this.data.isLogin) {
  283. wx.navigateTo({
  284. url: '/pages/ucenter/coupon/coupon',
  285. })
  286. } else {
  287. this.toLogin()
  288. }
  289. },
  290. toAddress: function () {
  291. if (this.data.isLogin) {
  292. wx.navigateTo({
  293. url: '/pages/ucenter/address/address',
  294. })
  295. } else {
  296. this.toLogin()
  297. }
  298. }*/
  299. })