index.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  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. goyuyt(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/yuyt/yuyt'
  153. wx.navigateTo({
  154. url
  155. });
  156. },
  157. gozhanw(e){
  158. if (!this.data.isLogin) {
  159. let url = `/pages/login/phone_login/phone_login`;
  160. wx.navigateTo({
  161. url
  162. });
  163. return;
  164. }
  165. let url = '/pages/ucenter/zhanw/zhanw'
  166. wx.navigateTo({
  167. url
  168. });
  169. },
  170. goPurse(e) {
  171. if (!this.data.isLogin) {
  172. let url = `/pages/login/phone_login/phone_login`;
  173. wx.navigateTo({
  174. url
  175. });
  176. return;
  177. }
  178. let url = '/pages/ucenter/purse/purse'
  179. wx.navigateTo({
  180. url
  181. });
  182. },
  183. goCar(e) {
  184. if (!this.data.isLogin) {
  185. let url = `/pages/login/phone_login/phone_login`;
  186. wx.navigateTo({
  187. url
  188. });
  189. return;
  190. }
  191. let url = '/pages/ucenter/car/car'
  192. wx.navigateTo({
  193. url
  194. });
  195. },
  196. goMyChargeSation(e) {
  197. let url = '/pages/ucenter/mychargestation/mychargestation'
  198. wx.navigateTo({
  199. url
  200. });
  201. },
  202. goChargpileMonitor(e) {
  203. let url = '/pages/ucenter/chargpilemonitor/chargpilemonitor'
  204. wx.navigateTo({
  205. url
  206. });
  207. },
  208. goMyWorksheet(e) {
  209. let url = '/pages/ucenter/myworksheet/myworksheet'
  210. wx.navigateTo({
  211. url
  212. });
  213. },
  214. goAccountSecrity(e){
  215. if (!this.data.isLogin) {
  216. let url = `/pages/login/phone_login/phone_login`;
  217. wx.navigateTo({
  218. url
  219. });
  220. return;
  221. }
  222. if (this.phoneCheck()) {
  223. let url = '/pages/ucenter/accountsecurity/index/index'
  224. wx.navigateTo({
  225. url
  226. });
  227. }
  228. },
  229. goAgreement(){
  230. let url = '/pages/agreement/list'
  231. wx.navigateTo({
  232. url
  233. });
  234. },
  235. goHelp(){
  236. // wx.downloadFile({
  237. // //url: getApp().globalData.postHeadAgreement + '/restapi/wechat/updateUser',//要预览的PDF的地址
  238. // url: 'http://localhost:8080/aiconfig/index/downloadTest',//要预览的PDF的地址
  239. // success: function (res) {
  240. // console.log(res);
  241. // if (res.statusCode === 200) { //成功
  242. // var Path = res.tempFilePath //返回的文件临时地址,用于后面打开本地预览所用
  243. // wx.openDocument({
  244. // filePath: Path, //要打开的文件路径
  245. // success: function (res) {
  246. // console.log('打开PDF成功');
  247. // }
  248. // });
  249. // }
  250. // },
  251. // fail: function (res) {
  252. // console.log(res); //失败
  253. // }
  254. // });
  255. let url = '/pages/ucenter/help/help'
  256. wx.navigateTo({
  257. url
  258. });
  259. },
  260. goNotice(){
  261. if (!this.data.isLogin) {
  262. let url = `/pages/login/phone_login/phone_login`;
  263. wx.navigateTo({
  264. url
  265. });
  266. return;
  267. }
  268. let url = '/pages/ucenter/notice/notice'
  269. wx.navigateTo({
  270. url
  271. });
  272. },
  273. toindex(e) {
  274. let url = '/pages/index/index';
  275. // wx.reLaunch({
  276. // url
  277. // });
  278. wx.navigateBack();
  279. },
  280. goCarControl(){
  281. wx.navigateTo({
  282. url: '/pages/ucenter/control/carControl',
  283. })
  284. },
  285. goBatteryControl(){
  286. // wx.scanCode({
  287. // success (res) {
  288. // wx.navigateTo({
  289. // url: '/pages/ucenter/control/batteryControl?code=' + res.result,
  290. // })
  291. // }
  292. // })
  293. wx.navigateTo({
  294. url: '/pages/ucenter/control/batteryControl',
  295. })
  296. }
  297. /*,
  298. goLogin: function() {
  299. wx.navigateTo({
  300. url: '/pages/auth/tologin/tologin?from=ucenter',
  301. })
  302. },
  303. callService: function () {
  304. wx.makePhoneCall({
  305. phoneNumber: '17621230884'
  306. })
  307. },
  308. afterSale: function () {
  309. wx.showModal({
  310. title: '提示',
  311. content: '请在官网或APP中申请售后',
  312. showCancel: false,
  313. confirmColor: '#b4282d',
  314. success: function (res) {
  315. if (res.confirm) {
  316. console.log('用户点击确定')
  317. } else if (res.cancel) {
  318. console.log('用户点击取消')
  319. }
  320. }
  321. })
  322. },
  323. toLogin: function () {
  324. wx.navigateTo({
  325. url: '/pages/auth/tologin/tologin',
  326. })
  327. },
  328. toOrder: function () {
  329. if (this.data.isLogin) {
  330. wx.navigateTo({
  331. url: '/pages/ucenter/order/order',
  332. })
  333. } else {
  334. this.toLogin()
  335. }
  336. },
  337. toCoupon: function () {
  338. if (this.data.isLogin) {
  339. wx.navigateTo({
  340. url: '/pages/ucenter/coupon/coupon',
  341. })
  342. } else {
  343. this.toLogin()
  344. }
  345. },
  346. toAddress: function () {
  347. if (this.data.isLogin) {
  348. wx.navigateTo({
  349. url: '/pages/ucenter/address/address',
  350. })
  351. } else {
  352. this.toLogin()
  353. }
  354. }*/
  355. })