东风启辰小程序端
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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