mine.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. const util = require('../../../utils/utils.js');
  2. var app = getApp();
  3. Page({
  4. data: {
  5. list: [
  6. {
  7. id: 0,
  8. imgUrl: 'http://resource.bike.hanyiyun.com/weapp/notice.png',
  9. name: '公告列表'
  10. },
  11. {
  12. id: 1,
  13. imgUrl: '/img/shenqing.png',
  14. name: '申请还车点'
  15. },
  16. {
  17. id: 2,
  18. imgUrl: 'http://resource.bike.hanyiyun.com/weapp/aid.png',
  19. name: '帮助中心'
  20. },
  21. {
  22. id: 3,
  23. imgUrl: '/img/fnakui.png',
  24. name: '问题反馈'
  25. }
  26. ],
  27. open: true,
  28. user: '',
  29. balance: '', //我的钱包
  30. phone: [],
  31. actionSheetHidden: true,
  32. state: '',
  33. arr: [],
  34. show: '',
  35. imgUrl: 'http://resource.bike.hanyiyun.com/xiaobanma/mineBg.png',
  36. time: wx.getStorageSync('home').customer_service_time,
  37. showOnlinePhone: wx.getStorageSync('home').setting,
  38. screenHeight: '',
  39. adHeight: '',
  40. img: app.globalData.imgUrl,
  41. title: app.globalData.title,
  42. setting:{},
  43. navBarHeight: 0, // 导航栏高度
  44. menuRight: 0, // 胶囊距右方间距(方保持左、右间距一致)
  45. menuTop: 0, // 胶囊距底部间距(保持底部间距一致)
  46. menuHeight: 0,
  47. },
  48. //返回首页
  49. skipIndex() {
  50. console.log(app.globalData.compatible)
  51. if (app.globalData.compatible) {
  52. wx.reLaunch({
  53. url: '/pages/compatible/index/index',
  54. })
  55. } else {
  56. wx.reLaunch({
  57. url: '/pages/index/index',
  58. })
  59. }
  60. },
  61. showService: function (e) {
  62. this.setData({
  63. open: !this.data.open
  64. })
  65. },
  66. realname: function () {
  67. wx.navigateTo({
  68. url: '/pages/real_name/real_name?state2=2&index=1&hidden=true',
  69. })
  70. },
  71. getUserInfo: function (e) {
  72. console.log(e)
  73. wx.showLoading({
  74. title: '登陆中请稍等...',
  75. mask: true
  76. })
  77. var that = this;
  78. if (e.detail.rawData) {
  79. var data = e.detail.userInfo
  80. wx.setStorageSync('userInfo', data)
  81. if (wx.getStorageSync('home').id != undefined) {
  82. data.area_id = wx.getStorageSync('home').id
  83. }
  84. console.log(data)
  85. app.request("/auth/weapp-userinfo-sync", data, "POST").then(res => {
  86. if (res.statusCode == 200) {
  87. wx.showToast({
  88. title: '授权成功',
  89. icon: 'none'
  90. })
  91. wx.setStorageSync('userInfo', res.data)
  92. // wx.navigateBack()
  93. that.setData({ user: res.data })
  94. } else {
  95. wx.showToast({
  96. title: '登陆失败请重试',
  97. icon: 'none'
  98. })
  99. }
  100. })
  101. } else {
  102. wx.showToast({
  103. title: '授权失败',
  104. icon: 'none'
  105. })
  106. }
  107. },
  108. tuichu() {
  109. wx.showModal({
  110. title: '提示',
  111. content: '确定要退出当前账户吗?',
  112. success: function (res) {
  113. if (res.confirm) {
  114. wx.reLaunch({
  115. url: '/pages/authentication/authentication',
  116. })
  117. }
  118. }
  119. })
  120. },
  121. jumpPage: function (e) {
  122. let index = e.currentTarget.dataset.idx;
  123. switch (index) {
  124. case 0:
  125. wx.navigateTo({
  126. url: '/pages/announcement_list/announcement_list',
  127. })
  128. break;
  129. case 1:
  130. wx.navigateTo({
  131. url: '/pages/apply/apply',
  132. })
  133. break;
  134. case 2:
  135. wx.navigateTo({
  136. url: '/pages/personal/help/help'
  137. })
  138. break;
  139. case 3:
  140. wx.navigateTo({
  141. url: '/pages/personal/helpDetail/helpDetail?show=14'
  142. })
  143. break;
  144. default:
  145. if (app.globalData.compatible) {
  146. wx.reLaunch({
  147. url: '/pages/compatible/index/index',
  148. })
  149. } else {
  150. wx.reLaunch({
  151. url: '/pages/index/index',
  152. })
  153. }
  154. }
  155. },
  156. userinfo: function (e) {
  157. var that = this;
  158. wx.showLoading({
  159. title: '加载中...',
  160. mask: true
  161. })
  162. app.request("/me", '', "GET").then(res => {
  163. 200 == res.statusCode && wx.setStorageSync("userInfo", res.data), that.setData({
  164. user: res.data
  165. }), wx.hideLoading()
  166. })
  167. },
  168. onLoad: function (options) {
  169. wx.setNavigationBarTitle({
  170. title: app.globalData.title
  171. })
  172. const that = this;
  173. // 获取系统信息
  174. const systemInfo = wx.getSystemInfoSync();
  175. // 胶囊按钮位置信息
  176. const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
  177. // 导航栏高度 = 状态栏高度 + 44
  178. that.setData({
  179. navBarHeight:systemInfo.statusBarHeight + 44,
  180. menuRight:systemInfo.screenWidth - menuButtonInfo.right,
  181. menuTop:menuButtonInfo.top,
  182. menuHeight:menuButtonInfo.height
  183. })
  184. this.setData({
  185. setting: wx.getStorageSync('setting')
  186. })
  187. var phones = wx.getStorageSync('home').customer_service_phone
  188. this.setData({
  189. phone: this.data.phone.concat(phones)
  190. });
  191. //获取实名认证状态
  192. },
  193. buy: function () {
  194. wx.navigateTo({
  195. url: '/pages/recharge/recharge',
  196. })
  197. },
  198. look() {
  199. wx.navigateTo({
  200. url: '/pages/riding_card/riding_card',
  201. })
  202. },
  203. onReady: function () {
  204. },
  205. phone1: util.throttle(function (e) {
  206. var phone = this.data.phone[0];
  207. if(phone!==''&&phone!==undefined){
  208. wx.makePhoneCall({
  209. phoneNumber: phone,
  210. })
  211. }else{
  212. wx.makePhoneCall({
  213. phoneNumber:"037163211915",
  214. })
  215. }
  216. }, 1000),
  217. onShow: function () {
  218. var that = this;
  219. that.setData({ time: wx.getStorageSync('home').customer_service_time });
  220. var area_id = ''
  221. if (wx.getStorageSync('home').id != undefined) {
  222. area_id = wx.getStorageSync('home').id
  223. }
  224. var data = {
  225. 'area_id': area_id
  226. }
  227. app.request("/card_riding/user_card", data, "GET").then(res => {
  228. console.log(res)
  229. that.setData({ arr: res.data.user_card, show: res.data.is_card_begin })
  230. })
  231. this.userinfo();
  232. app.request("/user/status", '', "GET").then(res => {
  233. console.log(res)
  234. if (res.statusCode == 200) {
  235. if (res.data.is_card_certified == 1) {
  236. this.setData({
  237. state: '已实名'
  238. })
  239. } else {
  240. this.setData({
  241. state: '未实名'
  242. })
  243. }
  244. wx.setStorageSync('userState', res.data)
  245. }
  246. })
  247. },
  248. onHide: function () {
  249. },
  250. onUnload: function () {
  251. },
  252. onPullDownRefresh: function () {
  253. wx.showNavigationBarLoading();
  254. var that = this;
  255. app.request("/me", '', "GET").then(res => {
  256. 200 == res.statusCode && wx.setStorageSync("userInfo", res.data), that.setData({
  257. user: res.data
  258. })
  259. wx.hideNavigationBarLoading()
  260. wx.stopPullDownRefresh();
  261. })
  262. },
  263. onReachBottom: function () {
  264. },
  265. onShareAppMessage: function () {
  266. }
  267. })