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