东风启辰小程序端
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

186 lines
4.1KB

  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. provinceArr: [],//省
  14. provinceValue: 0,//选中的省下标
  15. storeArr: [],//店铺
  16. storeValue: 0,//选中的店铺下标
  17. realname:"",
  18. },
  19. /**
  20. * 生命周期函数--监听页面加载
  21. */
  22. onLoad: function (options) {
  23. app.globalData.nowPage = 2;
  24. if (app.globalData.openid) {
  25. this.loadFun();
  26. } else {
  27. app.globalData.openidSuccessFuc = this.loadFun;
  28. }
  29. },
  30. loadFun:function(){
  31. this.getJobList();
  32. this.getUserLocation();
  33. },
  34. /**
  35. * 生命周期函数--监听页面初次渲染完成
  36. */
  37. onReady: function () {
  38. },
  39. /**
  40. * 生命周期函数--监听页面显示
  41. */
  42. onShow: function () {
  43. },
  44. /**
  45. * 生命周期函数--监听页面隐藏
  46. */
  47. onHide: function () {
  48. },
  49. /**
  50. * 生命周期函数--监听页面卸载
  51. */
  52. onUnload: function () {
  53. },
  54. /**
  55. * 页面相关事件处理函数--监听用户下拉动作
  56. */
  57. onPullDownRefresh: function () {
  58. },
  59. /**
  60. * 页面上拉触底事件的处理函数
  61. */
  62. onReachBottom: function () {
  63. },
  64. /**
  65. * 用户点击右上角分享
  66. */
  67. onShareAppMessage: function () {
  68. },
  69. agreementState: function () {//协议
  70. this.setData({
  71. isAgreement: !this.data.isAgreement
  72. })
  73. },
  74. agreementControl: function () {
  75. this.setData({
  76. agreement: !this.data.agreement
  77. })
  78. },
  79. getJobList:function(){
  80. app.wxRequest(app.globalData.urlRoot + "userInfo/getJobList", {}, res => {
  81. if(res.code==200){
  82. this.setData({
  83. jobList:res.data
  84. })
  85. }
  86. },this)
  87. },
  88. jobChange:function(e){
  89. this.setData({
  90. jobValue:e.detail.value
  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. } else {
  114. wx.showToast({
  115. title: res.msg,
  116. icon: "none"
  117. })
  118. }
  119. }, this);
  120. },
  121. provinceChane: function (e) {//选中省
  122. this.setData({
  123. provinceValue: e.detail.value,
  124. storeArr: this.data.provinceArr[e.detail.value].children,
  125. storeValue: 0
  126. })
  127. },
  128. storeChane: function (e) {//选中店铺
  129. this.setData({
  130. storeValue: e.detail.value,
  131. })
  132. },
  133. getRealname: function (e) {//获取用户输入的姓名
  134. this.data.realname = e.detail.value;
  135. },
  136. submitMsg: function () {
  137. if(!this.data.realname){
  138. wx.showToast({
  139. title: '请输入姓名',
  140. icon:'none'
  141. })
  142. return;
  143. }
  144. if (!this.data.isAgreement) {
  145. wx.showToast({
  146. title: '请同意协议',
  147. icon: 'none'
  148. })
  149. return;
  150. }
  151. var data = {
  152. realName:this.data.realname,
  153. jobId: this.data.jobList[this.data.jobValue].jobId,
  154. jobDetail: this.data.jobList[this.data.jobValue].jobDetail,
  155. agentDetail: this.data.storeArr[this.data.storeValue]['agent_detail'],
  156. agentCode: this.data.storeArr[this.data.storeValue]['agent_code'],
  157. city: this.data.provinceArr[this.data.provinceValue]['province']
  158. }
  159. app.wxRequest(app.globalData.urlRoot + "certificationInfo/submitCertificationInfoData", data,res=>{
  160. if (res.code == 200) {
  161. wx.navigateBack({
  162. delta: 1,
  163. })
  164. }else{
  165. wx.showToast({
  166. title: res.msg,
  167. icon:'none'
  168. })
  169. }
  170. },this,"POST");
  171. }
  172. })