东风启辰小程序端
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
5 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. //index.js
  2. //获取应用实例
  3. const app = getApp()
  4. Page({
  5. data: {
  6. imgUrl: app.globalData.urlStatic,//图片路径
  7. phoneInputShow:false,//是否显示电话输入框
  8. siteSelect: false,//是否显示位置选择框
  9. provinceArr:[],//省
  10. provinceValue: 0,//选中的省下标
  11. storeArr:[],//店铺
  12. storeValue:0,//选中的店铺下标
  13. swiperCurrent:0,//swiper选中的元素下标
  14. verificationCode: '获取验证码',//验证码文案
  15. sendCode: true,
  16. appointment:true,
  17. subscribeData: {
  18. realname:"",//姓名
  19. mobile:"",//手机号
  20. captcha:"",//验证码
  21. province:"",//省份
  22. agent_code: "",//经销商编码
  23. agentDetail: "",//经销商详细信息
  24. parentOpenid: app.globalData.friendOpenid,//好友openid
  25. },
  26. startAdvertisingUrl:'',//开屏广告路径
  27. isStartAdvertising: 1,//开屏广告透明度
  28. isStartAdvertisingShow: true,//是否显示开屏广告
  29. // isRegister:false,//查询是否已注册
  30. bannerList:[],//banner列表
  31. videoList:[],//视频列表
  32. videoVideoControls:false,//是否显示视频控件
  33. mainShow:false,
  34. isOnce:false,
  35. userData:null,
  36. },
  37. onLoad: function () {
  38. app.globalData.nowPage = 1;
  39. if (app.globalData.isFirstLogin) {
  40. this.getStartAdvertising();
  41. }else{
  42. if (app.globalData.openid) {
  43. this.loadFun();
  44. } else {
  45. app.globalData.openidSuccessFuc = this.loadFun;
  46. }
  47. }
  48. },
  49. loadFun: function () {
  50. if (app.globalData.userInfoData) {
  51. this.setData({
  52. userData: app.globalData.userInfoData
  53. })
  54. }
  55. if (app.globalData.userMobile) {
  56. this.data.subscribeData.mobile = app.globalData.userMobile;
  57. this.setData({
  58. phoneInputShow: true,
  59. subscribeData: this.data.subscribeData
  60. })
  61. this.getUserLocation();
  62. }
  63. if (app.globalData.isFirstLogin) {
  64. this.getHomeBanner();//获取banner
  65. this.getHomeVideo();//获取视频
  66. } else {
  67. if (app.globalData.indexData.bannerList){
  68. this.setData({
  69. bannerList: app.globalData.indexData.bannerList
  70. })
  71. } else {
  72. this.getHomeBanner();//获取banner
  73. }
  74. if (app.globalData.indexData.videoList) {
  75. this.setData({
  76. videoList: app.globalData.indexData.videoList
  77. })
  78. } else {
  79. this.getHomeVideo();//获取视频
  80. }
  81. if (app.globalData.indexData.provinceArr){
  82. this.setData({
  83. provinceArr: app.globalData.indexData.provinceArr,
  84. storeArr: app.globalData.indexData.storeArr,
  85. provinceValue: app.globalData.indexData.provinceValue,
  86. storeValue: app.globalData.indexData.storeValue
  87. })
  88. this.data.subscribeData.province = this.data.provinceArr[this.data.provinceValue].province;
  89. this.data.subscribeData.agentDetail = this.data.storeArr[this.data.storeValue].agent_detail;
  90. this.data.subscribeData.agent_code = this.data.storeArr[this.data.storeValue].agent_code;
  91. }
  92. }
  93. // if (!app.globalData.isRegister) {
  94. // this.getOrderInfo();
  95. // }
  96. this.setData({
  97. mainShow: true,
  98. isStartAdvertisingShow: this.data.isOnce ? true : app.globalData.isFirstLogin,
  99. // isRegister: app.globalData.isRegister
  100. })
  101. },
  102. provinceChane: function (e) {//选中省
  103. this.setData({
  104. provinceValue: e.detail.value,
  105. storeArr: this.data.provinceArr[e.detail.value].children,
  106. storeValue:0
  107. })
  108. this.data.subscribeData.province = this.data.provinceArr[this.data.provinceValue].province;
  109. this.data.subscribeData.agentDetail = this.data.storeArr[this.data.storeValue].agent_detail;
  110. this.data.subscribeData.agent_code = this.data.storeArr[this.data.storeValue].agent_code;
  111. },
  112. storeChane: function (e) {//选中店铺
  113. this.setData({
  114. storeValue: e.detail.value,
  115. })
  116. this.data.subscribeData.agentDetail = this.data.storeArr[this.data.storeValue].agent_detail;
  117. this.data.subscribeData.agent_code = this.data.storeArr[this.data.storeValue].agent_code;
  118. },
  119. getUserPhone:function(e){//获取用户手机号
  120. this.setData({
  121. phoneInputShow: true
  122. })
  123. if (!app.globalData.indexData.provinceArr) {
  124. this.getUserLocation();//获取用户当前位置
  125. }
  126. if (e.detail.errMsg=='getPhoneNumber:ok'){
  127. app.getMobile(e.detail.encryptedData, e.detail.iv,res=>{
  128. if (res.code == 200) {
  129. if (res.data && res.data.decodeData){
  130. this.data.subscribeData.mobile = res.data.decodeData.phoneNumber;
  131. this.setData({
  132. subscribeData: this.data.subscribeData
  133. })
  134. }
  135. } else {
  136. wx.showToast({
  137. title: res.msg,
  138. icon: "none"
  139. })
  140. }
  141. },this);
  142. }
  143. },
  144. getUserLocation:function(e){
  145. wx.getLocation({
  146. type: 'gcj02', //
  147. success:(res)=>{
  148. // console.log(res);
  149. this.getDistributorList(res.longitude, res.latitude);
  150. },
  151. fail:(res)=>{
  152. this.getDistributorList("", "");
  153. },
  154. complete:(res)=>{
  155. this.setData({
  156. siteSelect: true,
  157. })
  158. }
  159. })
  160. },
  161. prevImg(){//上一张图片
  162. if (this.data.swiperCurrent>0) {
  163. this.setData({
  164. swiperCurrent: this.data.swiperCurrent-=1,
  165. })
  166. }
  167. },
  168. nextImg() {//下一张图片
  169. if (this.data.swiperCurrent < this.data.bannerList.length-1) {
  170. this.setData({
  171. swiperCurrent: this.data.swiperCurrent+=1,
  172. })
  173. }
  174. },
  175. swiperChange(e){//通过鼠标滑动改变swiper时
  176. if (e.detail.source == "touch"){
  177. this.setData({
  178. swiperCurrent: e.detail.current,
  179. })
  180. }
  181. },
  182. getDistributorList: function (longitude, latitude){//获取经销商列表
  183. app.wxRequest(app.globalData.urlRoot + "agent/getAgentList", { longitude: longitude, latitude: latitude}, res => {
  184. if (res.code == 200) {
  185. this.setData({
  186. provinceArr: res.data.list,
  187. storeArr: res.data.list[res.data.nearData.provinceIndex].children,
  188. provinceValue: res.data.nearData.provinceIndex,
  189. storeValue: res.data.nearData.cityIndex
  190. })
  191. this.data.subscribeData.province = this.data.provinceArr[this.data.provinceValue].province;
  192. this.data.subscribeData.agentDetail = this.data.storeArr[this.data.storeValue].agent_detail;
  193. this.data.subscribeData.agent_code = this.data.storeArr[this.data.storeValue].agent_code;
  194. app.globalData.indexData.provinceArr = res.data.list;
  195. app.globalData.indexData.storeArr = res.data.list[res.data.nearData.provinceIndex].children;
  196. app.globalData.indexData.provinceValue = res.data.nearData.provinceIndex;
  197. app.globalData.indexData.storeValue = res.data.nearData.cityIndex;
  198. } else {
  199. wx.showToast({
  200. title: res.msg,
  201. icon: "none"
  202. })
  203. }
  204. }, this);
  205. },
  206. getCode: function (e) {//获取验证码
  207. if (!app.mobileVerify(this.data.subscribeData.mobile)) {
  208. if (this.data.subscribeData.mobile){
  209. wx.showToast({
  210. title: '请输入正确的电话',
  211. icon: 'none'
  212. })
  213. }else{
  214. wx.showToast({
  215. title: '请输入电话',
  216. icon: 'none'
  217. })
  218. }
  219. return;
  220. }
  221. if (!this.data.sendCode){
  222. return;
  223. }
  224. this.data.sendCode = false;
  225. app.wxRequest(app.globalData.urlRoot + "captcha/sendCaptcha", { mobile: this.data.subscribeData.mobile }, res => {
  226. if (res.code == 200) {
  227. this.countDown();
  228. wx.showToast({
  229. title: '验证码获取成功',
  230. icon: "none"
  231. })
  232. this.setData({
  233. verificationCode:60
  234. })
  235. } else {
  236. this.data.sendCode = true;
  237. wx.showToast({
  238. title: res.msg,
  239. icon: "none"
  240. })
  241. }
  242. },this)
  243. },
  244. countDown: function () {//倒计时
  245. setTimeout(() => {
  246. this.setData({
  247. verificationCode: this.data.verificationCode - 1
  248. })
  249. if (this.data.verificationCode > 0) {
  250. this.countDown();
  251. } else {
  252. this.setData({
  253. verificationCode: "获取验证码"
  254. })
  255. this.data.sendCode = true;
  256. }
  257. }, 1000);
  258. },
  259. getRealname: function (e) {//获取用户输入的姓名
  260. this.data.subscribeData.realname = e.detail.value;
  261. },
  262. getMobile: function (e) {//获取用户输入的电话
  263. this.data.subscribeData.mobile = e.detail.value;
  264. },
  265. getCaptcha: function (e) {//获取用户输入的验证码
  266. this.data.subscribeData.captcha = e.detail.value;
  267. },
  268. subscribeFun: function (e) {//预约鉴赏
  269. if (!this.data.subscribeData.realname) {
  270. wx.showToast({
  271. title: '请输入姓名',
  272. icon: "none"
  273. })
  274. return;
  275. }
  276. if (!this.data.subscribeData.mobile) {
  277. wx.showToast({
  278. title: '请输入电话',
  279. icon: "none"
  280. })
  281. return;
  282. }
  283. if (!this.data.subscribeData.captcha) {
  284. wx.showToast({
  285. title: '请输入验证码',
  286. icon: "none"
  287. })
  288. return;
  289. }
  290. if (!this.data.appointment) {
  291. return;
  292. }
  293. this.data.appointment = false;
  294. app.wxRequest(app.globalData.urlRoot + "userInfo/submitOrderInfo", this.data.subscribeData, res => {
  295. this.data.appointment = true;
  296. if (res.code == 200) {
  297. wx.showToast({
  298. title: '预约成功'
  299. })
  300. this.data.subscribeData.realname = "";
  301. this.data.subscribeData.captcha = "";
  302. this.setData({
  303. subscribeData: this.data.subscribeData,
  304. verificationCode: '获取验证码',
  305. })
  306. // this.setData({
  307. // isRegister:true
  308. // })
  309. // app.globalData.isRegister = true;
  310. app.globalData.userMobile = this.data.subscribeData.mobile;
  311. // wx.redirectTo({
  312. // url: "../myCenter/myCenter?sourcePage='home'"
  313. // })
  314. } else {
  315. wx.showToast({
  316. title: res.msg,
  317. icon: "none"
  318. })
  319. }
  320. }, this, "POST")
  321. },
  322. getStartAdvertising: function () {//获取开屏广告
  323. app.wxRequest(app.globalData.urlRoot + "home/getStartAdvertising", {}, res => {
  324. this.data.isOnce = true;
  325. if (app.globalData.openid) {
  326. this.loadFun();
  327. } else {
  328. app.globalData.openidSuccessFuc = this.loadFun;
  329. }
  330. if(res.code==200){
  331. this.setData({
  332. startAdvertisingUrl: res.data.picurl,
  333. mainShow:true
  334. })
  335. app.globalData.isFirstLogin = false;
  336. setTimeout(() => {
  337. this.setData({
  338. isStartAdvertising: 0
  339. })
  340. setTimeout(()=>{
  341. this.setData({
  342. isStartAdvertisingShow:false,
  343. })
  344. },1000);
  345. }, 3000);
  346. }
  347. },this);
  348. },
  349. getHomeBanner: function () {//获取banner
  350. app.wxRequest(app.globalData.urlRoot + "home/getHomeBanner", {}, res => {
  351. if (res.code == 200) {
  352. this.setData({
  353. bannerList:res.data
  354. })
  355. app.globalData.indexData.bannerList = res.data;
  356. }
  357. }, this);
  358. },
  359. getHomeVideo: function () {//获取视频
  360. app.wxRequest(app.globalData.urlRoot + "home/getHomeVideo", {}, res => {
  361. if (res.code == 200) {
  362. this.setData({
  363. videoList:res.data[0]
  364. })
  365. app.globalData.indexData.videoList = res.data[0];
  366. }
  367. }, this);
  368. },
  369. hideVideoControls: function () {//显示视频控件
  370. wx.createVideoContext("video").play();
  371. this.setData({
  372. videoVideoControls:true
  373. })
  374. },
  375. getOrderInfo: function () {//查询是否已注册
  376. app.wxRequest(app.globalData.urlRoot + "userInfo/getOrderInfo", {}, res => {
  377. if (res.code == 200) {
  378. if (res.data) {
  379. // this.setData({
  380. // isRegister: true
  381. // })
  382. // app.globalData.isRegister = true;
  383. app.globalData.userMobile = res.data.mobile;
  384. }else{
  385. if (app.globalData.userMobile) {
  386. this.data.subscribeData.mobile = app.globalData.userMobile;
  387. this.setData({
  388. phoneInputShow:true,
  389. subscribeData: this.data.subscribeData
  390. })
  391. this.getUserLocation();
  392. }
  393. }
  394. } else {
  395. console.log(res.msg)
  396. }
  397. }, this);
  398. },
  399. /**
  400. * 用户点击右上角分享
  401. */
  402. onShareAppMessage: function () {
  403. return app.sharePack();
  404. },
  405. getUserWxMsg:function(e){
  406. if (e.detail.errMsg == "getUserInfo:ok") {
  407. this.setData({
  408. userData: e.detail.userInfo
  409. })
  410. app.submitUserMsg(e.detail.userInfo.avatarUrl, e.detail.userInfo.nickName);
  411. }
  412. }
  413. })