东风启辰小程序端
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 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
5 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  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/v2/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. if(res.data.awardResult){
  232. this.prizeControl();
  233. }else{
  234. this.prizeControl2();
  235. }
  236. // wx.showToast({
  237. // title: '预约成功',
  238. // mask:true
  239. // })
  240. // setTimeout(()=>{
  241. // this.closeXieyi();
  242. // },1500)
  243. // this.data.subscribeData.realname = "";
  244. // this.data.subscribeData.captcha = "";
  245. // this.setData({
  246. // subscribeData: this.data.subscribeData,
  247. // verificationCode: '获取验证码',
  248. // })
  249. // this.setData({
  250. // siteSelect: false
  251. // })
  252. // this.setData({
  253. // isRegister: true
  254. // })
  255. // app.globalData.isRegister = true;
  256. // app.globalData.userMobile = this.data.subscribeData.mobile;
  257. } else {
  258. wx.showToast({
  259. title: res.msg,
  260. icon: "none"
  261. })
  262. }
  263. }, this, "POST")
  264. },
  265. provinceDataChange: function (e) {
  266. if (e.detail.column == 0) {
  267. var city = [];
  268. for (let i = 0; i < this.data.provinceDataAll[e.detail.value].children.length; i++) {
  269. city.push(this.data.provinceDataAll[e.detail.value].children[i].city);
  270. }
  271. this.data.provinceDataArr[1] = city;
  272. this.setData({
  273. provinceDataArr: this.data.provinceDataArr
  274. })
  275. }
  276. },
  277. provinceDataChane: function (e) {
  278. this.setData({
  279. provinceDataValue: e.detail.value,
  280. nowProvince: this.data.provinceDataArr[0][e.detail.value[0]] + " " + this.data.provinceDataArr[1][e.detail.value[1]],
  281. storeArr: this.data.provinceDataAll[e.detail.value[0]].children[e.detail.value[1]].children,
  282. storeValue: 0
  283. })
  284. },
  285. storeChane: function (e) {
  286. this.setData({
  287. storeValue: e.detail.value
  288. })
  289. },
  290. getUserPhone: function (e) {//获取用户手机号
  291. if (e.detail.errMsg == 'getPhoneNumber:ok') {
  292. app.getMobile(e.detail.encryptedData, e.detail.iv, res => {
  293. if (res.code == 200) {
  294. this.setData({
  295. phoneInputShow: true
  296. })
  297. this.cutType();
  298. if (res.data && res.data.decodeData) {
  299. this.data.subscribeData.mobile = res.data.decodeData.phoneNumber;
  300. this.setData({
  301. subscribeData: this.data.subscribeData
  302. })
  303. }
  304. } else {
  305. wx.showToast({
  306. title: res.msg,
  307. icon: "none"
  308. })
  309. }
  310. }, this);
  311. }
  312. },
  313. agreementState: function () {//协议
  314. this.setData({
  315. isAgreement: !this.data.isAgreement
  316. })
  317. },
  318. lookMore: function () {
  319. wx.navigateTo({
  320. url: '/pages/moreType/moreType',
  321. })
  322. },
  323. showSite: function () {//显示地址选择框
  324. if (!this.data.siteSelect) {
  325. if (!app.globalData.myCenterData) {
  326. } else {
  327. this.setData({
  328. siteSelect: true
  329. })
  330. }
  331. }
  332. },
  333. getUserLocation: function (e) {
  334. wx.getLocation({
  335. type: 'wgs84', //wgs84 gcj02
  336. success: (res) => {
  337. this.getDistributorList(res.longitude, res.latitude);
  338. },
  339. fail: (res) => {
  340. this.getDistributorList("", "");
  341. }
  342. })
  343. },
  344. agreementControl: function () {
  345. this.setData({
  346. agreement: !this.data.agreement
  347. })
  348. },
  349. cutType:function(){
  350. this.setData({
  351. mobileType: this.data.mobileType==1?2:1
  352. })
  353. },
  354. getUserWxMsg:function(e){//通过微信获取用户信息
  355. if (e.detail.errMsg == "getUserInfo:ok") {
  356. this.data.userData = {};
  357. this.data.userData.avatarUrl = e.detail.userInfo.avatarUrl;
  358. this.data.userData.nickName = e.detail.userInfo.nickName;
  359. this.setData({
  360. userData: this.data.userData
  361. })
  362. app.submitUserMsg(e.detail.userInfo.avatarUrl, e.detail.userInfo.nickName);
  363. }
  364. this.subscribeFun();
  365. },
  366. ruleControl(){//控制规则显示状态
  367. this.setData({
  368. ruleShow:!this.data.ruleShow
  369. })
  370. },
  371. prizeControl(){//控制获奖弹窗显示状态
  372. this.setData({
  373. prizeShow:!this.data.prizeShow
  374. })
  375. },
  376. prizeControl2(){//控制获奖弹窗显示状态
  377. this.setData({
  378. prizeShow2:!this.data.prizeShow2
  379. })
  380. },
  381. addressControl(){//立即领取
  382. this.setData({
  383. addressShow: !this.data.addressShow
  384. })
  385. if (this.data.addressShow) {
  386. app.globalData.skipType = 'mycenter';
  387. }
  388. },
  389. getAddress: function () {//获取地址
  390. app.wxRequest(app.globalData.urlRoot + "address/getAddressV2", {}, res => {
  391. if (res.code == 200) {
  392. if (res.data) {
  393. this.setData({
  394. isAddress:true
  395. })
  396. }
  397. }
  398. }, this)
  399. }
  400. }
  401. })