东风启辰小程序端
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.

270 lines
7.6KB

  1. // pages/supplement/supplement.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. imgUrl: app.globalData.urlStatic,//图片路径
  9. agreement: false,
  10. isAgreement: true,//是否同意协议
  11. jobList: [],
  12. jobValue: 0,
  13. provinceDataAll: null,//地区所有数据
  14. provinceDataArr: [[""], [""]],//省市数据
  15. provinceDataValue: [0, 0],//选中的省市下标
  16. nowProvince: "",//选中的省市文字
  17. storeArr: [],//专营店数据
  18. storeValue: 0,//选中的专营店下标
  19. realname: "",
  20. // jobDetail: "",
  21. httpState: false,
  22. },
  23. /**
  24. * 生命周期函数--监听页面加载
  25. */
  26. onLoad: function (options) {
  27. app.globalData.nowPage = 2;
  28. if (app.globalData.openid) {
  29. this.loadFun();
  30. } else {
  31. app.globalData.openidSuccessFuc = this.loadFun;
  32. }
  33. },
  34. loadFun: function () {
  35. // this.getJobList();
  36. this.getUserLocation();
  37. var authenticationStatus = app.globalData.authenticationStatus;
  38. if (authenticationStatus && authenticationStatus.realName) {
  39. this.setData({
  40. realname: authenticationStatus.realName
  41. })
  42. }
  43. },
  44. /**
  45. * 生命周期函数--监听页面初次渲染完成
  46. */
  47. onReady: function () {
  48. },
  49. /**
  50. * 生命周期函数--监听页面显示
  51. */
  52. onShow: function () {
  53. },
  54. /**
  55. * 生命周期函数--监听页面隐藏
  56. */
  57. onHide: function () {
  58. },
  59. /**
  60. * 生命周期函数--监听页面卸载
  61. */
  62. onUnload: function () {
  63. },
  64. /**
  65. * 页面相关事件处理函数--监听用户下拉动作
  66. */
  67. onPullDownRefresh: function () {
  68. },
  69. /**
  70. * 页面上拉触底事件的处理函数
  71. */
  72. onReachBottom: function () {
  73. },
  74. /**
  75. * 用户点击右上角分享
  76. */
  77. onShareAppMessage: function () {
  78. return app.sharePack();
  79. },
  80. agreementState: function () {//协议
  81. this.setData({
  82. isAgreement: !this.data.isAgreement
  83. })
  84. },
  85. agreementControl: function () {
  86. this.setData({
  87. agreement: !this.data.agreement
  88. })
  89. },
  90. getJobList: function () {
  91. app.wxRequest(app.globalData.urlRoot + "userInfo/getJobList", {}, res => {
  92. if (res.code == 200) {
  93. this.setData({
  94. jobList: res.data
  95. })
  96. var authenticationStatus = app.globalData.authenticationStatus;
  97. if (authenticationStatus && authenticationStatus.jobId) {
  98. for (let i = 0; i < res.data.length; i++) {
  99. if (res.data[i].jobId == authenticationStatus.jobId) {
  100. this.setData({
  101. jobValue: i,
  102. jobDetail: res.data[i].jobDetail
  103. })
  104. break;
  105. }
  106. }
  107. }
  108. }
  109. }, this)
  110. },
  111. jobChange: function (e) {
  112. this.setData({
  113. jobValue: e.detail.value
  114. })
  115. },
  116. getUserLocation: function (e) {
  117. wx.getLocation({
  118. type: 'gcj02', //wgs84
  119. success: (res) => {
  120. this.getDistributorList(res.longitude, res.latitude);
  121. },
  122. fail: (res) => {
  123. this.getDistributorList("", "");
  124. }
  125. })
  126. },
  127. getDistributorList: function (longitude, latitude) {//获取经销商列表
  128. app.wxRequest(app.globalData.urlRoot + "agent/getAgentList", { longitude: longitude, latitude: latitude }, res => {
  129. if (res.code == 200) {
  130. //整理数据
  131. var datas = res.data;
  132. var province = [];
  133. var city = [];
  134. for (let i = 0; i < res.data.list.length; i++) {
  135. province.push(res.data.list[i].province);
  136. }
  137. for (let j = 0; j < res.data.list[res.data.nearData.provinceIndex].children.length; j++) {
  138. city.push(res.data.list[res.data.nearData.provinceIndex].children[j].city)
  139. }
  140. //将数据赋值给变量
  141. this.setData({
  142. provinceDataAll: res.data.list,
  143. provinceDataArr: [province, city],
  144. provinceDataValue: [res.data.nearData.provinceIndex, res.data.nearData.cityIndex],
  145. nowProvince: province[res.data.nearData.provinceIndex] + " " + city[res.data.nearData.cityIndex],
  146. storeArr: res.data.list[res.data.nearData.provinceIndex].children[res.data.nearData.cityIndex].children,
  147. storeValue: res.data.nearData.agentIndex
  148. })
  149. } else {
  150. wx.showToast({
  151. title: res.msg,
  152. icon: "none"
  153. })
  154. }
  155. }, this);
  156. },
  157. getRealname: function (e) {//获取用户输入的姓名
  158. this.data.realname = e.detail.value;
  159. },
  160. // getJobDetail: function (e) {//获取用户输入的姓名
  161. // this.data.jobDetail = e.detail.value;
  162. // },
  163. submitMsg: function () {
  164. if (!this.data.realname) {
  165. wx.showToast({
  166. title: '请输入姓名',
  167. icon: 'none'
  168. })
  169. return;
  170. }
  171. // if (!this.data.jobDetail) {
  172. // wx.showToast({
  173. // title: '请输入职业',
  174. // icon: 'none'
  175. // })
  176. // return;
  177. // }
  178. if (!this.data.isAgreement) {
  179. wx.showToast({
  180. title: '请同意协议',
  181. icon: 'none'
  182. })
  183. return;
  184. }
  185. if (this.data.httpState) {
  186. return;
  187. }
  188. this.data.httpState = true;
  189. var data = {
  190. realName: this.data.realname,
  191. // jobId: this.data.jobList[this.data.jobValue].jobId,
  192. // jobDetail: this.data.jobDetail,
  193. agentDetail: this.data.storeArr[this.data.storeValue]['agent_detail'],
  194. agentCode: this.data.storeArr[this.data.storeValue]['agent_code'],
  195. city: this.data.provinceDataArr[1][this.data.provinceDataValue[1]],
  196. province: this.data.provinceDataArr[0][this.data.provinceDataValue[0]]
  197. }
  198. app.wxRequest(app.globalData.urlRoot + "certificationInfo/submitCertificationInfoData", data, res => {
  199. this.data.httpState = false;
  200. if (res.code == 200) {
  201. if (!app.globalData.authenticationStatus) {
  202. app.globalData.authenticationStatus = {};
  203. }
  204. app.globalData.authenticationStatus.realName = this.data.realname
  205. // app.globalData.authenticationStatus.jobDetail = this.data.storeArr[this.data.storeValue]['agent_detail']
  206. app.globalData.authenticationStatus.city = data.city
  207. app.globalData.authenticationStatus.agentDetail = data.agentDetail
  208. // wx.navigateBack({
  209. // delta: 1,
  210. // })
  211. app.globalData.isStar.agentDetail = data.agentDetail;
  212. app.globalData.isStar.realName = data.realName;
  213. app.globalData.isStar.province = data.province;
  214. app.globalData.isStar.city = data.city;
  215. var isStar = wx.getStorageSync('isStar');
  216. isStar.agentDetail = data.agentDetail;
  217. isStar.realName = data.realName;
  218. isStar.province = data.province;
  219. isStar.city = data.city;
  220. wx.setStorageSync('isStar', isStar);
  221. wx.redirectTo({
  222. url: '../poster/poster',
  223. })
  224. } else {
  225. wx.showToast({
  226. title: res.msg,
  227. icon: 'none'
  228. })
  229. }
  230. }, this, "POST");
  231. },
  232. provinceDataChange: function (e) {
  233. if (e.detail.column == 0) {
  234. var city = [];
  235. for (let i = 0; i < this.data.provinceDataAll[e.detail.value].children.length; i++) {
  236. city.push(this.data.provinceDataAll[e.detail.value].children[i].city);
  237. }
  238. this.data.provinceDataArr[1] = city;
  239. this.setData({
  240. provinceDataArr: this.data.provinceDataArr
  241. })
  242. }
  243. },
  244. provinceDataChane: function (e) {
  245. this.setData({
  246. provinceDataValue: e.detail.value,
  247. nowProvince: this.data.provinceDataArr[0][e.detail.value[0]] + " " + this.data.provinceDataArr[1][e.detail.value[1]],
  248. storeArr: this.data.provinceDataAll[e.detail.value[0]].children[e.detail.value[1]].children,
  249. storeValue: 0
  250. })
  251. },
  252. storeChane: function (e) {//选中店铺
  253. this.setData({
  254. storeValue: e.detail.value,
  255. })
  256. }
  257. })