东风启辰小程序端
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
vor 5 Jahren
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  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.scene,//好友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. kvurl: null,//顶部大图
  37. kvurlH:0,
  38. showAppointment:false,
  39. placing:false,
  40. buyState:false,
  41. isStartAdvertisingFunState:false,
  42. playBtnDeg:0,
  43. videoShow:false,
  44. swiperGroup:{
  45. one:{
  46. nums:4,
  47. current:0
  48. },
  49. two: {
  50. nums: 4,
  51. current: 0
  52. },
  53. three: {
  54. nums: 7,
  55. current: 0
  56. },
  57. four: {
  58. nums: 2,
  59. current: 0
  60. }
  61. }
  62. },
  63. onLoad: function (options) {
  64. if (app.globalData.isFirstLogin) {
  65. console.log("第一次进入");
  66. wx.reportAnalytics('event_source_launch', {
  67. source: options.source ? options.source :0
  68. });
  69. }
  70. app.globalData.nowPage = 1;
  71. if (app.globalData.isFirstLogin) {
  72. this.getStartAdvertising();
  73. }else{
  74. if (app.globalData.openid) {
  75. this.loadFun();
  76. } else {
  77. app.globalData.openidSuccessFuc = this.loadFun;
  78. }
  79. }
  80. },
  81. loadFun: function () {
  82. if (!app.globalData.addPageEnterState.index) {
  83. app.addPageEnter(1);
  84. app.globalData.addPageEnterState.index = true;
  85. }
  86. this.setData({
  87. kvurl: app.globalData.kvurl,
  88. kvurlH: app.globalData.kvurlH
  89. })
  90. if (app.globalData.userInfoData) {
  91. this.setData({
  92. userData: app.globalData.userInfoData
  93. })
  94. }
  95. if (app.globalData.userMobile) {
  96. this.data.subscribeData.mobile = app.globalData.userMobile;
  97. this.setData({
  98. phoneInputShow: true,
  99. subscribeData: this.data.subscribeData
  100. })
  101. }
  102. if (app.globalData.isFirstLogin) {
  103. this.getHomeVideo();//获取视频
  104. } else {
  105. if (app.globalData.indexData.videoList) {
  106. this.setData({
  107. videoList: app.globalData.indexData.videoList
  108. })
  109. } else {
  110. this.getHomeVideo();//获取视频
  111. }
  112. }
  113. this.setData({
  114. mainShow: true,
  115. isStartAdvertisingShow: this.data.isOnce ? true : app.globalData.isFirstLogin,
  116. // isRegister: app.globalData.isRegister
  117. })
  118. },
  119. onShow: function () {
  120. if (app.globalData.getBuyState) {
  121. this.getBuyStates();
  122. } else {
  123. app.globalData.buyStateSuccessFuc = this.getBuyStates;
  124. }
  125. this.setData({
  126. siteSelect: false
  127. })
  128. this.data.subscribeData.parentOpenid = app.globalData.scene;
  129. },
  130. getBuyStates:function(){
  131. this.setData({
  132. buyState: app.globalData.getBuyState.success
  133. })
  134. },
  135. provinceChane: function (e) {//选中省
  136. this.setData({
  137. provinceValue: e.detail.value,
  138. storeArr: this.data.provinceArr[e.detail.value].children,
  139. storeValue:0
  140. })
  141. this.data.subscribeData.province = this.data.provinceArr[this.data.provinceValue].province;
  142. this.data.subscribeData.agentDetail = this.data.storeArr[this.data.storeValue].agent_detail;
  143. this.data.subscribeData.agent_code = this.data.storeArr[this.data.storeValue].agent_code;
  144. },
  145. storeChane: function (e) {//选中店铺
  146. this.setData({
  147. storeValue: e.detail.value,
  148. })
  149. this.data.subscribeData.agentDetail = this.data.storeArr[this.data.storeValue].agent_detail;
  150. this.data.subscribeData.agent_code = this.data.storeArr[this.data.storeValue].agent_code;
  151. },
  152. getUserPhone:function(e){//获取用户手机号
  153. this.setData({
  154. phoneInputShow: true
  155. })
  156. // if (!app.globalData.indexData.provinceArr) {
  157. // this.getUserLocation();//获取用户当前位置
  158. // }
  159. if (e.detail.errMsg=='getPhoneNumber:ok'){
  160. app.getMobile(e.detail.encryptedData, e.detail.iv,res=>{
  161. if (res.code == 200) {
  162. if (res.data && res.data.decodeData){
  163. this.data.subscribeData.mobile = res.data.decodeData.phoneNumber;
  164. this.setData({
  165. subscribeData: this.data.subscribeData
  166. })
  167. }
  168. } else {
  169. wx.showToast({
  170. title: res.msg,
  171. icon: "none"
  172. })
  173. }
  174. },this);
  175. }
  176. },
  177. getUserLocation:function(e){
  178. wx.getLocation({
  179. type: 'gcj02', //
  180. success:(res)=>{
  181. // console.log(res);
  182. this.getDistributorList(res.longitude, res.latitude);
  183. },
  184. fail:(res)=>{
  185. this.getDistributorList("", "");
  186. },
  187. complete:(res)=>{
  188. this.setData({
  189. siteSelect: true,
  190. })
  191. }
  192. })
  193. },
  194. prevImg(){//上一张图片
  195. if (this.data.swiperCurrent>0) {
  196. this.setData({
  197. swiperCurrent: this.data.swiperCurrent-=1,
  198. })
  199. }
  200. },
  201. nextImg() {//下一张图片
  202. if (this.data.swiperCurrent < this.data.bannerList.length-1) {
  203. this.setData({
  204. swiperCurrent: this.data.swiperCurrent+=1,
  205. })
  206. }
  207. },
  208. // swiperChange(e){//通过鼠标滑动改变swiper时
  209. // this.setData({
  210. // swiperCurrent: e.detail.current,
  211. // })
  212. // },
  213. getDistributorList: function (longitude, latitude){//获取经销商列表
  214. app.wxRequest(app.globalData.urlRoot + "agent/getAgentList", { longitude: longitude, latitude: latitude}, res => {
  215. if (res.code == 200) {
  216. this.setData({
  217. provinceArr: res.data.list,
  218. storeArr: res.data.list[res.data.nearData.provinceIndex].children,
  219. provinceValue: res.data.nearData.provinceIndex,
  220. storeValue: res.data.nearData.cityIndex
  221. })
  222. this.data.subscribeData.province = this.data.provinceArr[this.data.provinceValue].province;
  223. this.data.subscribeData.agentDetail = this.data.storeArr[this.data.storeValue].agent_detail;
  224. this.data.subscribeData.agent_code = this.data.storeArr[this.data.storeValue].agent_code;
  225. app.globalData.indexData.provinceArr = res.data.list;
  226. app.globalData.indexData.storeArr = res.data.list[res.data.nearData.provinceIndex].children;
  227. app.globalData.indexData.provinceValue = res.data.nearData.provinceIndex;
  228. app.globalData.indexData.storeValue = res.data.nearData.cityIndex;
  229. } else {
  230. wx.showToast({
  231. title: res.msg,
  232. icon: "none"
  233. })
  234. }
  235. }, this);
  236. },
  237. getCode: function (e) {//获取验证码
  238. if (!app.mobileVerify(this.data.subscribeData.mobile)) {
  239. if (this.data.subscribeData.mobile){
  240. wx.showToast({
  241. title: '请输入正确的电话',
  242. icon: 'none'
  243. })
  244. }else{
  245. wx.showToast({
  246. title: '请输入电话',
  247. icon: 'none'
  248. })
  249. }
  250. return;
  251. }
  252. if (!this.data.sendCode){
  253. return;
  254. }
  255. this.data.sendCode = false;
  256. app.wxRequest(app.globalData.urlRoot + "captcha/sendCaptcha", { mobile: this.data.subscribeData.mobile }, res => {
  257. if (res.code == 200) {
  258. this.countDown();
  259. wx.showToast({
  260. title: '验证码获取成功',
  261. icon: "none"
  262. })
  263. this.setData({
  264. verificationCode:60
  265. })
  266. } else {
  267. this.data.sendCode = true;
  268. wx.showToast({
  269. title: res.msg,
  270. icon: "none"
  271. })
  272. }
  273. },this)
  274. },
  275. countDown: function () {//倒计时
  276. setTimeout(() => {
  277. this.setData({
  278. verificationCode: this.data.verificationCode - 1
  279. })
  280. if (this.data.verificationCode > 0) {
  281. this.countDown();
  282. } else {
  283. this.setData({
  284. verificationCode: "获取验证码"
  285. })
  286. this.data.sendCode = true;
  287. }
  288. }, 1000);
  289. },
  290. getRealname: function (e) {//获取用户输入的姓名
  291. this.data.subscribeData.realname = e.detail.value;
  292. },
  293. getMobile: function (e) {//获取用户输入的电话
  294. this.data.subscribeData.mobile = e.detail.value;
  295. },
  296. getCaptcha: function (e) {//获取用户输入的验证码
  297. this.data.subscribeData.captcha = e.detail.value;
  298. },
  299. subscribeFun: function (e) {//预约鉴赏
  300. if (!this.data.subscribeData.realname) {
  301. wx.showToast({
  302. title: '请输入姓名',
  303. icon: "none"
  304. })
  305. return;
  306. }
  307. if (!this.data.subscribeData.mobile) {
  308. wx.showToast({
  309. title: '请输入电话',
  310. icon: "none"
  311. })
  312. return;
  313. }
  314. if (!this.data.subscribeData.captcha) {
  315. wx.showToast({
  316. title: '请输入验证码',
  317. icon: "none"
  318. })
  319. return;
  320. }
  321. if (!this.data.appointment) {
  322. return;
  323. }
  324. this.data.appointment = false;
  325. app.wxRequest(app.globalData.urlRoot + "userInfo/submitOrderInfo", this.data.subscribeData, res => {
  326. this.data.appointment = true;
  327. if (res.code == 200) {
  328. wx.showToast({
  329. title: '预约成功'
  330. })
  331. this.data.subscribeData.realname = "";
  332. this.data.subscribeData.captcha = "";
  333. this.setData({
  334. subscribeData: this.data.subscribeData,
  335. verificationCode: '获取验证码',
  336. })
  337. this.setData({
  338. siteSelect: false
  339. })
  340. // this.setData({
  341. // isRegister:true
  342. // })
  343. // app.globalData.isRegister = true;
  344. app.globalData.userMobile = this.data.subscribeData.mobile;
  345. // wx.redirectTo({
  346. // url: "../myCenter/myCenter?sourcePage='home'"
  347. // })
  348. } else {
  349. wx.showToast({
  350. title: res.msg,
  351. icon: "none"
  352. })
  353. }
  354. }, this, "POST")
  355. },
  356. getStartAdvertising: function () {//获取开屏广告
  357. app.wxRequest(app.globalData.urlRoot + "home/getStartAdvertising", {}, res => {
  358. this.data.isOnce = true;
  359. if(res.code==200){
  360. this.setData({
  361. startAdvertisingUrl: res.data.picurl,
  362. mainShow:true,
  363. kvurl: res.data.kvurl
  364. })
  365. app.globalData.kvurl = res.data.kvurl;
  366. app.globalData.isFirstLogin = false;
  367. setTimeout(() => {
  368. this.isStartAdvertisingFun();
  369. }, 1000);
  370. }
  371. if (app.globalData.openid) {
  372. this.loadFun();
  373. } else {
  374. app.globalData.openidSuccessFuc = this.loadFun;
  375. }
  376. },this);
  377. },
  378. isStartAdvertisingFun:function(){
  379. if (this.data.isStartAdvertisingFunState){
  380. return;
  381. }
  382. this.data.isStartAdvertisingFunState = true;
  383. setTimeout(() => {
  384. const query = wx.createSelectorQuery()
  385. query.select('.kvurlImg').boundingClientRect()
  386. query.selectViewport().scrollOffset()
  387. query.exec((res) => {
  388. if (res.data && res.data[0]) {
  389. this.setData({
  390. kvurlH: res.data[0].height
  391. })
  392. app.globalData.kvurlH = res.data[0].height;
  393. }
  394. })
  395. }, 200)
  396. this.setData({
  397. isStartAdvertising: 0
  398. })
  399. setTimeout(() => {
  400. this.setData({
  401. isStartAdvertisingShow: false,
  402. })
  403. }, 1000);
  404. },
  405. getHomeBanner: function () {//获取banner
  406. app.wxRequest(app.globalData.urlRoot + "home/getHomeBanner", {}, res => {
  407. if (res.code == 200) {
  408. this.setData({
  409. bannerList:res.data
  410. })
  411. app.globalData.indexData.bannerList = res.data;
  412. }
  413. }, this);
  414. },
  415. getHomeVideo: function () {//获取视频
  416. app.wxRequest(app.globalData.urlRoot + "home/getHomeVideo", {}, res => {
  417. if (res.code == 200) {
  418. this.setData({
  419. videoList:res.data[0]
  420. })
  421. app.globalData.indexData.videoList = res.data[0];
  422. }
  423. }, this);
  424. },
  425. hideVideoControls: function () {//显示视频控件
  426. wx.createVideoContext("video").play();
  427. this.setData({
  428. videoVideoControls:true
  429. })
  430. },
  431. getOrderInfo: function () {//查询是否已注册
  432. app.wxRequest(app.globalData.urlRoot + "userInfo/getOrderInfo", {}, res => {
  433. if (res.code == 200) {
  434. if (res.data) {
  435. // this.setData({
  436. // isRegister: true
  437. // })
  438. // app.globalData.isRegister = true;
  439. app.globalData.userMobile = res.data.mobile;
  440. }else{
  441. if (app.globalData.userMobile) {
  442. this.data.subscribeData.mobile = app.globalData.userMobile;
  443. this.setData({
  444. phoneInputShow:true,
  445. subscribeData: this.data.subscribeData
  446. })
  447. }
  448. }
  449. } else {
  450. console.log(res.msg)
  451. }
  452. }, this);
  453. },
  454. /**
  455. * 用户点击右上角分享
  456. */
  457. onShareAppMessage: function () {
  458. return app.sharePack();
  459. },
  460. getUserWxMsg:function(e){
  461. if (e.detail.errMsg == "getUserInfo:ok") {
  462. this.setData({
  463. userData: e.detail.userInfo
  464. })
  465. app.submitUserMsg(e.detail.userInfo.avatarUrl, e.detail.userInfo.nickName);
  466. }
  467. },
  468. showSite: function () {//显示地址选择框
  469. if (!this.data.siteSelect) {
  470. if (!app.globalData.indexData.provinceArr) {
  471. this.getUserLocation();//获取用户当前位置
  472. }else{
  473. this.setData({
  474. siteSelect:true
  475. })
  476. }
  477. }
  478. },
  479. lookMore: function () {
  480. wx.navigateTo({
  481. url: '/pages/moreType/moreType',
  482. })
  483. },
  484. vrLookCar: function () {
  485. wx.navigateTo({
  486. url: '/pages/vrLookCar/vrLookCar',
  487. })
  488. },
  489. lookConfigure: function () {
  490. wx.navigateTo({
  491. url: '/pages/configure/configure',
  492. })
  493. },
  494. openAppointment:function(){//预约
  495. this.setData({
  496. showAppointment: !this.data.showAppointment
  497. })
  498. },
  499. placingControl:function(){
  500. if (app.globalData.getBuyState.success != this.data.buyState){
  501. this.setData({
  502. buyState: app.globalData.getBuyState.success
  503. })
  504. }
  505. this.setData({
  506. placing: !this.data.placing
  507. })
  508. },
  509. swiperChange:function(e){
  510. var num = e.currentTarget.dataset.num;
  511. if(num==1){
  512. this.data.swiperGroup.one.current = e.detail.current;
  513. } else if (num == 2) {
  514. this.data.swiperGroup.two.current = e.detail.current;
  515. } else if (num == 3) {
  516. this.data.swiperGroup.three.current = e.detail.current;
  517. } else if (num == 4) {
  518. this.data.swiperGroup.four.current = e.detail.current;
  519. }
  520. this.setData({
  521. swiperGroup: this.data.swiperGroup
  522. })
  523. },
  524. leftSlide:function(e){
  525. var num = e.currentTarget.dataset.num;
  526. if (num == 1 && this.data.swiperGroup.one.current>0) {
  527. this.data.swiperGroup.one.current-=1;
  528. } else if (num == 2 && this.data.swiperGroup.two.current > 0) {
  529. this.data.swiperGroup.two.current -= 1;
  530. } else if (num == 3 && this.data.swiperGroup.three.current > 0) {
  531. this.data.swiperGroup.three.current -= 1;
  532. } else if (num == 4 && this.data.swiperGroup.four.current > 0) {
  533. this.data.swiperGroup.four.current -= 1;
  534. }
  535. this.setData({
  536. swiperGroup: this.data.swiperGroup
  537. })
  538. },
  539. rightSlide: function (e) {
  540. var num = e.currentTarget.dataset.num;
  541. if (num == 1 && this.data.swiperGroup.one.current < this.data.swiperGroup.one.nums-1) {
  542. this.data.swiperGroup.one.current += 1;
  543. } else if (num == 2 && this.data.swiperGroup.two.current < this.data.swiperGroup.two.nums - 1) {
  544. this.data.swiperGroup.two.current += 1;
  545. } else if (num == 3 && this.data.swiperGroup.three.current < this.data.swiperGroup.three.nums - 1) {
  546. this.data.swiperGroup.three.current += 1;
  547. } else if (num == 4 && this.data.swiperGroup.four.current < this.data.swiperGroup.four.nums - 1) {
  548. this.data.swiperGroup.four.current += 1;
  549. }
  550. this.setData({
  551. swiperGroup: this.data.swiperGroup
  552. })
  553. },
  554. playVideo:function(){
  555. var animation = wx.createAnimation({
  556. duration: 300
  557. });
  558. animation.rotate(360).step();
  559. this.setData({
  560. playBtnDeg: animation.export()
  561. })
  562. setTimeout(()=>{
  563. this.setData({
  564. videoShow:true
  565. })
  566. var videoContext = wx.createVideoContext("myVideo");
  567. videoContext.requestFullScreen({ direction:0});
  568. videoContext.play();
  569. animation.rotate(0).step();
  570. this.setData({
  571. playBtnDeg: animation.export()
  572. })
  573. },300);
  574. },
  575. closeFull:function(e){
  576. if (!e.detail.fullScreen) {
  577. this.setData({
  578. videoShow: false
  579. })
  580. }
  581. }
  582. })