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

5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
5 anni fa
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. // pages/yuyue/yuyue.js
  2. const app = getApp()
  3. Component({
  4. /**
  5. * 组件的属性列表
  6. */
  7. properties: {
  8. },
  9. /**
  10. * 组件的初始数据
  11. */
  12. data: {
  13. imgUrl: app.globalData.urlStatic,//图片路径
  14. agreement:false,
  15. isAgreement: true,//是否同意协议
  16. phoneInputShow: false,//是否显示电话输入框
  17. siteSelect: false,//是否显示位置选择框
  18. provinceDataAll: null,//地区所有数据
  19. provinceDataArr: [[""], [""]],//省市数据
  20. provinceDataValue: [0, 0],//选中的省市下标
  21. nowProvince: "",//选中的省市文字
  22. storeArr: [],//专营店数据
  23. storeValue: 0,//选中的专营店下标
  24. verificationCode: '获取验证码',//验证码文案
  25. sendCode: true,
  26. appointment: true,
  27. mobile2:"",
  28. subscribeData: {
  29. realname: "",//姓名
  30. mobile: "",//手机号---无验证码
  31. captcha: "",//验证码
  32. province: "",//省份
  33. city:"",//城市
  34. agent_code: "",//经销商编码
  35. agentDetail: "",//经销商详细信息
  36. parentOpenid: app.globalData.parentOpenid,//好友openid
  37. scene: app.globalData.sceneSource
  38. },
  39. mobileType:2
  40. },
  41. ready:function(){
  42. if (app.globalData.openid) {
  43. this.loadFun();
  44. } else {
  45. app.globalData.openidSuccessFuc = this.loadFun;
  46. }
  47. },
  48. /**
  49. * 组件的方法列表
  50. */
  51. methods: {
  52. closeXieyi: function () {
  53. this.triggerEvent('yuyue')
  54. },
  55. getRealname: function (e) {//获取用户输入的姓名
  56. this.data.subscribeData.realname = e.detail.value;
  57. },
  58. getMobile: function (e) {//获取用户输入的电话---有验证码
  59. this.data.subscribeData.mobile = e.detail.value;
  60. },
  61. getMobile2: function (e) {//获取用户输入的电话---无验证码
  62. this.data.mobile2 = e.detail.value;
  63. },
  64. getCaptcha: function (e) {//获取用户输入的验证码
  65. this.data.subscribeData.captcha = e.detail.value;
  66. },
  67. loadFun: function () {
  68. if (app.globalData.userMobile) {
  69. this.data.subscribeData.mobile = app.globalData.userMobile;
  70. this.setData({
  71. phoneInputShow: true,
  72. subscribeData: this.data.subscribeData
  73. })
  74. }
  75. this.getUserLocation();//获取用户当前位置
  76. },
  77. getDistributorList: function (longitude, latitude) {//获取经销商列表
  78. app.wxRequest(app.globalData.urlRoot + "agent/getAgentList", { longitude: longitude, latitude: latitude }, res => {
  79. if (res.code == 200) {
  80. //整理数据
  81. var datas = res.data;
  82. var province = [];
  83. var city = [];
  84. for (let i = 0; i < res.data.list.length; i++) {
  85. province.push(res.data.list[i].province);
  86. }
  87. for (let j = 0; j < res.data.list[res.data.nearData.provinceIndex].children.length; j++) {
  88. city.push(res.data.list[res.data.nearData.provinceIndex].children[j].city)
  89. }
  90. //将数据赋值给变量
  91. this.setData({
  92. provinceDataAll: res.data.list,
  93. provinceDataArr: [province, city],
  94. provinceDataValue: [res.data.nearData.provinceIndex, res.data.nearData.cityIndex],
  95. nowProvince: province[res.data.nearData.provinceIndex] + " " + city[res.data.nearData.cityIndex],
  96. storeArr: res.data.list[res.data.nearData.provinceIndex].children[res.data.nearData.cityIndex].children,
  97. storeValue: res.data.nearData.agentIndex
  98. })
  99. } else {
  100. wx.showToast({
  101. title: res.msg,
  102. icon: "none"
  103. })
  104. }
  105. }, this);
  106. },
  107. getCode: function (e) {//获取验证码
  108. if (!app.mobileVerify(this.data.mobile2)) {
  109. if (this.data.mobile2) {
  110. wx.showToast({
  111. title: '请输入正确的电话',
  112. icon: 'none'
  113. })
  114. } else {
  115. wx.showToast({
  116. title: '请输入电话',
  117. icon: 'none'
  118. })
  119. }
  120. return;
  121. }
  122. if (!this.data.sendCode) {
  123. return;
  124. }
  125. this.data.sendCode = false;
  126. app.wxRequest(app.globalData.urlRoot + "captcha/sendCaptcha", { mobile: this.data.mobile2 }, res => {
  127. if (res.code == 200) {
  128. this.countDown();
  129. wx.showToast({
  130. title: '验证码获取成功',
  131. icon: "none"
  132. })
  133. this.setData({
  134. verificationCode: 60
  135. })
  136. } else {
  137. this.data.sendCode = true;
  138. wx.showToast({
  139. title: res.msg,
  140. icon: "none"
  141. })
  142. }
  143. }, this)
  144. },
  145. countDown: function () {//倒计时
  146. setTimeout(() => {
  147. this.setData({
  148. verificationCode: this.data.verificationCode - 1
  149. })
  150. if (this.data.verificationCode > 0) {
  151. this.countDown();
  152. } else {
  153. this.setData({
  154. verificationCode: "获取验证码"
  155. })
  156. this.data.sendCode = true;
  157. }
  158. }, 1000);
  159. },
  160. subscribeFun: function (e) {//预约鉴赏
  161. if (!this.data.subscribeData.realname) {
  162. wx.showToast({
  163. title: '请输入姓名',
  164. icon: "none"
  165. })
  166. return;
  167. }
  168. if (!this.data.mobile2 && this.data.mobileType==2) {
  169. wx.showToast({
  170. title: '请输入电话',
  171. icon: "none"
  172. })
  173. return;
  174. }
  175. if (this.data.mobileType == 2) {
  176. if (!this.data.subscribeData.captcha) {
  177. wx.showToast({
  178. title: '请输入验证码',
  179. icon: "none"
  180. })
  181. return;
  182. }
  183. }
  184. if (!this.data.isAgreement) {
  185. wx.showToast({
  186. title: '请同意协议',
  187. icon: 'none'
  188. })
  189. return;
  190. }
  191. if (!this.data.appointment) {
  192. return;
  193. }
  194. this.data.appointment = false;
  195. this.data.subscribeData.province = this.data.provinceDataArr[0][this.data.provinceDataValue[0]];
  196. this.data.subscribeData.city = this.data.provinceDataArr[1][this.data.provinceDataValue[1]];
  197. this.data.subscribeData.agent_code = this.data.storeArr[this.data.storeValue].agent_code;
  198. this.data.subscribeData.agentDetail = this.data.storeArr[this.data.storeValue].agent_detail;
  199. var sourceMobile = this.data.subscribeData.mobile;
  200. if(this.data.mobileType==2){
  201. this.data.subscribeData.mobile = this.data.mobile2;
  202. }
  203. this.data.subscribeData.parentOpenid = app.globalData.parentOpenid;
  204. app.wxRequest(app.globalData.urlRoot + "userInfo/submitOrderInfo", this.data.subscribeData, res => {
  205. this.data.subscribeData.mobile = sourceMobile;
  206. this.data.appointment = true;
  207. if (res.code == 200) {
  208. if (app.globalData.nowPage=='0'){
  209. wx.reLaunch({
  210. url: '/pages/index/index'
  211. })
  212. return;
  213. }
  214. wx.showToast({
  215. title: '预约成功',
  216. mask:true
  217. })
  218. setTimeout(()=>{
  219. this.closeXieyi();
  220. },1500)
  221. // this.data.subscribeData.realname = "";
  222. // this.data.subscribeData.captcha = "";
  223. // this.setData({
  224. // subscribeData: this.data.subscribeData,
  225. // verificationCode: '获取验证码',
  226. // })
  227. // this.setData({
  228. // siteSelect: false
  229. // })
  230. // this.setData({
  231. // isRegister: true
  232. // })
  233. // app.globalData.isRegister = true;
  234. // app.globalData.userMobile = this.data.subscribeData.mobile;
  235. } else {
  236. wx.showToast({
  237. title: res.msg,
  238. icon: "none"
  239. })
  240. }
  241. }, this, "POST")
  242. },
  243. provinceDataChange: function (e) {
  244. if (e.detail.column == 0) {
  245. var city = [];
  246. for (let i = 0; i < this.data.provinceDataAll[e.detail.value].children.length; i++) {
  247. city.push(this.data.provinceDataAll[e.detail.value].children[i].city);
  248. }
  249. this.data.provinceDataArr[1] = city;
  250. this.setData({
  251. provinceDataArr: this.data.provinceDataArr
  252. })
  253. }
  254. },
  255. provinceDataChane: function (e) {
  256. this.setData({
  257. provinceDataValue: e.detail.value,
  258. nowProvince: this.data.provinceDataArr[0][e.detail.value[0]] + " " + this.data.provinceDataArr[1][e.detail.value[1]],
  259. storeArr: this.data.provinceDataAll[e.detail.value[0]].children[e.detail.value[1]].children,
  260. storeValue: 0
  261. })
  262. },
  263. storeChane: function (e) {
  264. this.setData({
  265. storeValue: e.detail.value
  266. })
  267. },
  268. getUserPhone: function (e) {//获取用户手机号
  269. if (e.detail.errMsg == 'getPhoneNumber:ok') {
  270. app.getMobile(e.detail.encryptedData, e.detail.iv, res => {
  271. if (res.code == 200) {
  272. this.setData({
  273. phoneInputShow: true
  274. })
  275. this.cutType();
  276. if (res.data && res.data.decodeData) {
  277. this.data.subscribeData.mobile = res.data.decodeData.phoneNumber;
  278. this.setData({
  279. subscribeData: this.data.subscribeData
  280. })
  281. }
  282. } else {
  283. wx.showToast({
  284. title: res.msg,
  285. icon: "none"
  286. })
  287. }
  288. }, this);
  289. }
  290. },
  291. agreementState: function () {//协议
  292. this.setData({
  293. isAgreement: !this.data.isAgreement
  294. })
  295. },
  296. lookMore: function () {
  297. wx.navigateTo({
  298. url: '/pages/moreType/moreType',
  299. })
  300. },
  301. showSite: function () {//显示地址选择框
  302. if (!this.data.siteSelect) {
  303. if (!app.globalData.myCenterData) {
  304. } else {
  305. this.setData({
  306. siteSelect: true
  307. })
  308. }
  309. }
  310. },
  311. getUserLocation: function (e) {
  312. wx.getLocation({
  313. type: 'gcj02', //wgs84
  314. success: (res) => {
  315. this.getDistributorList(res.longitude, res.latitude);
  316. },
  317. fail: (res) => {
  318. this.getDistributorList("", "");
  319. }
  320. })
  321. },
  322. agreementControl: function () {
  323. this.setData({
  324. agreement: !this.data.agreement
  325. })
  326. },
  327. cutType:function(){
  328. this.setData({
  329. mobileType: this.data.mobileType==1?2:1
  330. })
  331. }
  332. }
  333. })