东风启辰小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

216 line
5.5KB

  1. // pages/myCenter/myCenter.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. imgUrl: app.globalData.urlStatic,//图片路径
  9. isLogin:false,//登录状态
  10. selectNow:0,//现在的选项
  11. taskNow:1,//现在的任务类型
  12. recordNow: 1,//现在的记录类型
  13. taskList: [//任务列表
  14. { name: "双子星LED大灯", bar: 1 },
  15. { name: "双子星LED大灯双子星LED大灯", bar: 2 },
  16. { name: "双子星LED大灯", bar: 3 },
  17. { name: "双子星LED大灯", bar: 4 },
  18. { name: "双子星LED大灯", bar: 4 },
  19. { name: "双子星LED大灯", bar: 4 },
  20. { name: "双子星LED大灯", bar: 4 },
  21. ],
  22. provinceArr: [],//省
  23. provinceValue: 0,//选中的省下标
  24. storeArr: [],//店铺
  25. storeValue: 0,//选中的店铺下标
  26. verificationCode: '获取验证码',//验证码文案
  27. sendCode: true,
  28. subscribeData: {
  29. realname: "",//姓名
  30. mobile: "",//手机号
  31. captcha: "",//验证码
  32. province: "",//省份
  33. agentDetail: "",//经销商详细信息
  34. parentOpenid: "",//好友openid
  35. }
  36. },
  37. /**
  38. * 生命周期函数--监听页面加载
  39. */
  40. onLoad: function (options) {
  41. },
  42. /**
  43. * 生命周期函数--监听页面初次渲染完成
  44. */
  45. onReady: function () {
  46. this.getUserLocation();
  47. },
  48. /**
  49. * 生命周期函数--监听页面显示
  50. */
  51. onShow: function () {
  52. },
  53. /**
  54. * 生命周期函数--监听页面隐藏
  55. */
  56. onHide: function () {
  57. },
  58. /**
  59. * 生命周期函数--监听页面卸载
  60. */
  61. onUnload: function () {
  62. },
  63. /**
  64. * 页面相关事件处理函数--监听用户下拉动作
  65. */
  66. onPullDownRefresh: function () {
  67. },
  68. /**
  69. * 页面上拉触底事件的处理函数
  70. */
  71. onReachBottom: function () {
  72. },
  73. /**
  74. * 用户点击右上角分享
  75. */
  76. onShareAppMessage: function () {
  77. },
  78. selectChange:function(e){
  79. this.setData({
  80. selectNow: e.currentTarget.dataset.value
  81. })
  82. },
  83. selectTask: function (e) {
  84. this.setData({
  85. taskNow: e.currentTarget.dataset.type
  86. })
  87. },
  88. selectRecord: function (e) {
  89. this.setData({
  90. recordNow: e.currentTarget.dataset.type
  91. })
  92. },
  93. getUserLocation: function (e) {
  94. wx.getLocation({
  95. type: 'gcj02', //wgs84
  96. success: (res) => {
  97. this.getDistributorList(res.longitude, res.latitude);
  98. },
  99. fail: (res) => {
  100. this.getDistributorList("", "");
  101. }
  102. })
  103. },
  104. getDistributorList: function (longitude, latitude) {//获取经销商列表
  105. app.wxRequest(app.globalData.urlRoot + "agent/getAgentList", { longitude: longitude, latitude: latitude }, res => {
  106. if (res.code == 200) {
  107. this.setData({
  108. provinceArr: res.data.list,
  109. storeArr: res.data.list[res.data.nearData.provinceIndex].children,
  110. provinceValue: res.data.nearData.provinceIndex,
  111. storeValue: res.data.nearData.cityIndex
  112. })
  113. this.data.subscribeData.province = this.data.provinceArr[this.data.provinceValue].province;
  114. this.data.subscribeData.agentDetail = this.data.storeArr[this.data.storeValue].agent_detail;
  115. } else {
  116. wx.showToast({
  117. title: res.msg,
  118. icon: "none"
  119. })
  120. }
  121. }, this);
  122. },
  123. provinceChane: function (e) {//选中省
  124. this.setData({
  125. provinceValue: e.detail.value,
  126. storeArr: this.data.provinceArr[e.detail.value].children,
  127. storeValue: 0
  128. })
  129. this.data.subscribeData.province = this.data.provinceArr[this.data.provinceValue].province;
  130. this.data.subscribeData.agentDetail = this.data.storeArr[this.data.storeValue].agent_detail;
  131. },
  132. storeChane: function (e) {//选中店铺
  133. this.setData({
  134. storeValue: e.detail.value,
  135. })
  136. this.data.subscribeData.agentDetail = this.data.storeArr[this.data.storeValue].agent_detail;
  137. },
  138. getCode: function (e) {//获取验证码
  139. app.wxRequest(app.globalData.urlRoot + "captcha/sendCaptcha", { mobile: '18831849567' }, res => {
  140. console.log(res);
  141. if (res.code == 200) {
  142. this.countDown();
  143. wx.showToast({
  144. title: '验证码获取成功',
  145. icon: "none"
  146. })
  147. this.setData({
  148. verificationCode: 60
  149. })
  150. this.data.sendCode = false;
  151. } else {
  152. wx.showToast({
  153. title: res.msg,
  154. icon: "none"
  155. })
  156. }
  157. }, this)
  158. },
  159. countDown: function () {//倒计时
  160. setTimeout(() => {
  161. this.setData({
  162. verificationCode: this.data.verificationCode - 1
  163. })
  164. if (this.data.verificationCode > 0) {
  165. this.countDown();
  166. } else {
  167. this.setData({
  168. verificationCode: "获取验证码"
  169. })
  170. this.data.sendCode = true;
  171. }
  172. }, 1000);
  173. },
  174. getRealname: function (e) {//获取用户输入的姓名
  175. this.data.subscribeData.realname = e.detail.value;
  176. },
  177. getMobile: function (e) {//获取用户输入的电话
  178. this.data.subscribeData.mobile = e.detail.value;
  179. },
  180. getCaptcha: function (e) {//获取用户输入的验证码
  181. this.data.subscribeData.captcha = e.detail.value;
  182. },
  183. subscribeFun: function (e) {//预约鉴赏
  184. console.log(this.data.subscribeData);
  185. app.wxRequest(app.globalData.urlRoot + "userInfo/submitOrderInfo", this.data.subscribeData, res => {
  186. console.log(res);
  187. if (res.code == 200) {
  188. } else {
  189. wx.showToast({
  190. title: res.msg,
  191. icon: "none"
  192. })
  193. }
  194. }, this, "POST")
  195. },
  196. getUserWxMsg:function(e){//获取用户信息
  197. console.log(e);
  198. }
  199. })