index.js 7.4 KB

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