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

yuyue.js 11KB

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