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

supplement.js 7.1KB

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