东风启辰小程序端
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

251 Zeilen
6.8KB

  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. },
  22. /**
  23. * 生命周期函数--监听页面加载
  24. */
  25. onLoad: function (options) {
  26. app.globalData.nowPage = 2;
  27. if (app.globalData.openid) {
  28. this.loadFun();
  29. } else {
  30. app.globalData.openidSuccessFuc = this.loadFun;
  31. }
  32. },
  33. loadFun:function(){
  34. // this.getJobList();
  35. this.getUserLocation();
  36. var authenticationStatus = app.globalData.authenticationStatus;
  37. if (authenticationStatus && authenticationStatus.realName){
  38. this.setData({
  39. realname: authenticationStatus.realName
  40. })
  41. }
  42. },
  43. /**
  44. * 生命周期函数--监听页面初次渲染完成
  45. */
  46. onReady: function () {
  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. agreementState: function () {//协议
  79. this.setData({
  80. isAgreement: !this.data.isAgreement
  81. })
  82. },
  83. agreementControl: function () {
  84. this.setData({
  85. agreement: !this.data.agreement
  86. })
  87. },
  88. getJobList:function(){
  89. app.wxRequest(app.globalData.urlRoot + "userInfo/getJobList", {}, res => {
  90. if(res.code==200){
  91. this.setData({
  92. jobList:res.data
  93. })
  94. var authenticationStatus = app.globalData.authenticationStatus;
  95. if (authenticationStatus && authenticationStatus.jobId) {
  96. for(let i=0;i<res.data.length;i++){
  97. if (res.data[i].jobId == authenticationStatus.jobId){
  98. this.setData({
  99. jobValue: i,
  100. jobDetail: res.data[i].jobDetail
  101. })
  102. break;
  103. }
  104. }
  105. }
  106. }
  107. },this)
  108. },
  109. jobChange:function(e){
  110. this.setData({
  111. jobValue:e.detail.value
  112. })
  113. },
  114. getUserLocation: function (e) {
  115. wx.getLocation({
  116. type: 'gcj02', //wgs84
  117. success: (res) => {
  118. this.getDistributorList(res.longitude, res.latitude);
  119. },
  120. fail: (res) => {
  121. this.getDistributorList("", "");
  122. }
  123. })
  124. },
  125. getDistributorList: function (longitude, latitude) {//获取经销商列表
  126. app.wxRequest(app.globalData.urlRoot + "agent/getAgentList", { longitude: longitude, latitude: latitude}, res => {
  127. if (res.code == 200) {
  128. //整理数据
  129. var datas = res.data;
  130. var province = [];
  131. var city = [];
  132. for (let i = 0; i < res.data.list.length; i++) {
  133. province.push(res.data.list[i].province);
  134. }
  135. for (let j = 0; j < res.data.list[0].children.length; j++) {
  136. city.push(res.data.list[0].children[j].city)
  137. }
  138. //将数据赋值给变量
  139. this.setData({
  140. provinceDataAll: res.data.list,
  141. provinceDataArr: [province, city],
  142. provinceDataValue: [res.data.nearData.provinceIndex, res.data.nearData.cityIndex],
  143. nowProvince: province[res.data.nearData.provinceIndex] + " " + city[res.data.nearData.cityIndex],
  144. storeArr: res.data.list[res.data.nearData.provinceIndex].children[res.data.nearData.cityIndex].children,
  145. storeValue: res.data.nearData.agentIndex
  146. })
  147. } else {
  148. wx.showToast({
  149. title: res.msg,
  150. icon: "none"
  151. })
  152. }
  153. }, this);
  154. },
  155. getRealname: function (e) {//获取用户输入的姓名
  156. this.data.realname = e.detail.value;
  157. },
  158. getJobDetail: function (e) {//获取用户输入的姓名
  159. this.data.jobDetail = e.detail.value;
  160. },
  161. submitMsg: function () {
  162. if(!this.data.realname){
  163. wx.showToast({
  164. title: '请输入姓名',
  165. icon:'none'
  166. })
  167. return;
  168. }
  169. if (!this.data.jobDetail) {
  170. wx.showToast({
  171. title: '请输入职业',
  172. icon: 'none'
  173. })
  174. return;
  175. }
  176. if (!this.data.isAgreement) {
  177. wx.showToast({
  178. title: '请同意协议',
  179. icon: 'none'
  180. })
  181. return;
  182. }
  183. var data = {
  184. realName:this.data.realname,
  185. // jobId: this.data.jobList[this.data.jobValue].jobId,
  186. jobDetail: this.data.jobDetail,
  187. agentDetail: this.data.storeArr[this.data.storeValue]['agent_detail'],
  188. agentCode: this.data.storeArr[this.data.storeValue]['agent_code'],
  189. city: this.data.provinceDataArr[1][this.data.provinceDataValue[1]],
  190. province: this.data.provinceDataArr[0][this.data.provinceDataValue[0]]
  191. }
  192. app.wxRequest(app.globalData.urlRoot + "certificationInfo/submitCertificationInfoData", data,res=>{
  193. if (res.code == 200) {
  194. if (!app.globalData.authenticationStatus) {
  195. app.globalData.authenticationStatus = {};
  196. }
  197. app.globalData.authenticationStatus.realName = this.data.realname
  198. app.globalData.authenticationStatus.jobDetail = this.data.storeArr[this.data.storeValue]['agent_detail']
  199. app.globalData.authenticationStatus.city = data.city
  200. app.globalData.authenticationStatus.agentDetail = data.agentDetail
  201. wx.navigateBack({
  202. delta: 1,
  203. })
  204. }else{
  205. wx.showToast({
  206. title: res.msg,
  207. icon:'none'
  208. })
  209. }
  210. },this,"POST");
  211. },
  212. provinceDataChange: function (e) {
  213. if (e.detail.column == 0) {
  214. var city = [];
  215. for (let i = 0; i < this.data.provinceDataAll[e.detail.value].children.length; i++) {
  216. city.push(this.data.provinceDataAll[e.detail.value].children[i].city);
  217. }
  218. this.data.provinceDataArr[1] = city;
  219. this.setData({
  220. provinceDataArr: this.data.provinceDataArr
  221. })
  222. }
  223. },
  224. provinceDataChane: function (e) {
  225. this.setData({
  226. provinceDataValue: e.detail.value,
  227. nowProvince: this.data.provinceDataArr[0][e.detail.value[0]] + " " + this.data.provinceDataArr[1][e.detail.value[1]],
  228. storeArr: this.data.provinceDataAll[e.detail.value[0]].children[e.detail.value[1]].children,
  229. storeValue: 0
  230. })
  231. },
  232. storeChane: function (e) {//选中店铺
  233. this.setData({
  234. storeValue: e.detail.value,
  235. })
  236. }
  237. })