myhome.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. <template>
  2. <view class="container">
  3. <page-top-bar />
  4. <view class="container">
  5. <view class="banner"><img src="https://business.coffunity.cn/uploads/banner.webp"
  6. style="width: 100%;"></img></view>
  7. <view class="person_info">
  8. <view class="avatar"><img :src="userInfo.avatar"></img></view>
  9. <view class="info">
  10. <view class="name">{{truncateString(userInfo.nickname, 10) }}</view>
  11. <view class="setup">
  12. <view class="vi"><button hover-class="none" open-type="contact"
  13. style="background: none; color: white; font-size:13px;"><img
  14. src="/static/images/kefu.png" style="width: 24px; height: 23px;"></img></button>
  15. </view>
  16. <view @click="onViewBind" class="vi"><img src="/static/images/shezhi.png"
  17. style="width: 24px; height: 24px;"></img></view>
  18. </view>
  19. <view class="tel">
  20. <view class="ico"><img src="/static/images/mobile.png" style="width: 11px; height: 11px;"></img>
  21. </view>
  22. <view class="telnmu" @click="onViewBind" v-if="userInfo.mobile">{{userInfo.mobile}}</view>
  23. <view class="telnmu" @click="onViewBind" v-else>请绑定手机</view>
  24. </view>
  25. </view>
  26. <view class="section1">
  27. <view class="column" @click="onViewCalendar">
  28. <view class="cell"><img src="/static/images/yuyue.png" style="width: 49px; height: 46px;"></img>
  29. </view>
  30. <view class="cell">预 约</view>
  31. </view>
  32. <view class="column" @click="onViewhd">
  33. <view class="cell"><img src="/static/images/huodong_da.png"
  34. style="width: 46px; height: 46px;"></img></view>
  35. <view class="cell">活 动</view>
  36. </view>
  37. <view class="column" @click="onVieworder">
  38. <view class="cell"><img src="/static/images/dingdan.png"
  39. style="width: 60px; height: 45px;"></img></view>
  40. <view class="cell">订 单</view>
  41. </view>
  42. <view class="column" @click="goSchool">
  43. <view class="cell"><img src="/static/images/aixin.png" style="width: 60px; height: 44px;"></img>
  44. </view>
  45. <view class="cell">爱心捐赠</view>
  46. </view>
  47. </view>
  48. <view class="section2">
  49. <view class="row">
  50. <view class="menu" @click="onViewaddress">
  51. <view class="name"><uni-icons type="right" size="16"></uni-icons>我的收货地址</view>
  52. </view>
  53. </view>
  54. <view class="row">
  55. <view class="menu" @click="onViewCalendar">
  56. <view class="name"><uni-icons type="right" size="16"></uni-icons>我的预约行程</view>
  57. </view>
  58. </view>
  59. <view class="row">
  60. <view class="menu" @click="onViewEquity">
  61. <view class="name"> <uni-icons type="right" size="16"></uni-icons>我的卡券</view>
  62. </view>
  63. </view>
  64. <view class="row">
  65. <view class="menu" @click="onOpenRenew">
  66. <view class="name"><uni-icons type="right" size="16"></uni-icons>成为会员</view>
  67. </view>
  68. </view>
  69. <view class="row" style="margin-top: 10px;padding-top: 0;">
  70. <!-- <view class="menu" >
  71. <view class="name"><uni-icons type="right" size="16"></uni-icons>分享小程序</view>
  72. </view> -->
  73. <button open-type="share" style="background: none;color: rgb(51, 51, 51);font-size: 17px; font-weight: normal;" hover-class="none"><uni-icons type="right"
  74. size="16"></uni-icons>分享小程序</button>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. <!-- 续费 -->
  80. <uni-popup ref="showRenewForm">
  81. <RenewForm :leveList="leveList" @onCloseRenew="onCloseRenew" />
  82. </uni-popup>
  83. <!-- vip表单 -->
  84. <uni-popup ref="vipForm">
  85. <VipForm :userInfo="userInfo" @onOpenRenew="onOpenRenew" />
  86. </uni-popup>
  87. <!-- 号外号外 -->
  88. <uni-popup ref="hwPopForm" type="center" style="z-index: 60;">
  89. <SoundForm :dataList="movieList"></SoundForm>
  90. </uni-popup>
  91. <page-btm-bar :active="5" />
  92. </view>
  93. </template>
  94. <script>
  95. import audio from '../../diy/audio.vue';
  96. import swiper from '../../diy/swiper.vue';
  97. import coupon from '../../diy/coupon';
  98. import module from '../../diy/Module';
  99. import home from '../../diy/home'
  100. import VipForm from '@/components/VipForm/VipForm.vue'
  101. import RenewForm from '@/components/RenewForm/RenewForm.vue'
  102. import SoundForm from '@/components/SoundForm/SoundForm.vue'
  103. import {
  104. mapState,
  105. mapMutations
  106. } from 'vuex'
  107. export default {
  108. components: {
  109. module,
  110. home,
  111. coupon,
  112. swiper,
  113. audio,
  114. VipForm,
  115. RenewForm,
  116. SoundForm
  117. },
  118. data() {
  119. return {
  120. List: {},
  121. loading: true,
  122. windowHeight: 0,
  123. is_template: false,
  124. is_popup: 1,
  125. params: [],
  126. paramsList: [],
  127. movieList: [],
  128. dialogBtnType: 2,
  129. dialogBtnStyle: {
  130. color: '#fff',
  131. backgroundColor: 'red',
  132. },
  133. is_coupon: true,
  134. cityCode: '',
  135. showMoreMenu: false,
  136. leveList: [],
  137. }
  138. },
  139. onLoad() {
  140. // #ifdef MP-ALIPAY
  141. this.$scope.onBeforeGetCoupon = this.onBeforeGetCoupon.bind(this)
  142. this.$scope.onGetCouponSuccess = this.onGetCouponSuccess.bind(this)
  143. this.$scope.onGetCouponFail = this.onGetCouponFail.bind(this)
  144. this.$scope.onUseImmediately = this.onUseImmediately.bind(this)
  145. this.$scope.onClose = this.onClose.bind(this)
  146. // #endif
  147. uni.hideTabBar();
  148. if (this.$store.state.store_id) {
  149. this.http();
  150. // #ifdef MP-ALIPAY
  151. this.getCouponList();
  152. // #endif
  153. }
  154. if (this.$store.state.systemInfo.set) {
  155. if (this.$store.state.systemInfo.set.is_pop != 0) {
  156. let is_pop = this.$store.state.systemInfo.set.is_pop;
  157. this.can_popup(is_pop);
  158. // is_pop == 2 ? this.Coupons() :
  159. // is_pop == 1 ? this.homePop(1) :
  160. // is_pop == 3 ? this.homePop(3) : '';
  161. }
  162. }
  163. uni.getSystemInfo({
  164. success: (e) => {
  165. this.windowHeight = e.windowHeight;
  166. }
  167. })
  168. },
  169. //分享小程序
  170. onShareAppMessage() {
  171. const promise = new Promise(resolve => {
  172. setTimeout(() => {
  173. resolve({
  174. title: this.systemInfo.title,
  175. imageUrl: this.detail.image[0],
  176. path: '/pages/home/home',
  177. })
  178. }, 2000)
  179. })
  180. return {
  181. title: this.systemInfo.title,
  182. imageUrl: this.detail.image[0],
  183. path: '/pages/home/home',
  184. promise
  185. }
  186. },
  187. onShow() {
  188. if (getApp().globalData.runMethod) {
  189. this.onOpenRenew();
  190. // 清除全局数据,以便下次不会再执行
  191. getApp().globalData.runMethod = false;
  192. }
  193. uni.hideTabBar();
  194. this.$store.dispatch('getOpenid', this.store_id);
  195. this.getOnLineList();
  196. this.initVipPackage();
  197. },
  198. created() {
  199. this.bus.$on('send', (data) => {
  200. this.$refs.popup.close();
  201. })
  202. },
  203. computed: {
  204. ...mapState(['systemInfo', 'store_id', 'userInfo']),
  205. dateRange() {
  206. const {
  207. store_id,
  208. userInfo,
  209. systemInfo
  210. } = this;
  211. return {
  212. store_id,
  213. userInfo,
  214. systemInfo
  215. }
  216. }
  217. },
  218. watch: {
  219. store_id(nVal) {
  220. if (nVal) {
  221. this.http();
  222. }
  223. },
  224. systemInfo(nVal) {
  225. uni.setNavigationBarTitle({
  226. title: ' '
  227. })
  228. },
  229. // 弹窗校检
  230. dateRange: {
  231. handler(val) {
  232. if (val.store_id && val.userInfo) {
  233. // #ifdef MP-ALIPAY
  234. this.getCouponList();
  235. // #endif
  236. }
  237. if (this.is_popup == 2) {
  238. return
  239. }
  240. if (val.systemInfo.set) {
  241. this.is_popup = 2;
  242. // 是否开启弹窗
  243. if (val.systemInfo.set.is_pop == 0) {
  244. return
  245. }
  246. // 优惠劵弹窗
  247. if (val.systemInfo.set.is_pop == 2) {
  248. if (val.store_id && val.userInfo) {
  249. this.can_popup(2)
  250. }
  251. }
  252. // 语音弹窗
  253. if (val.systemInfo.set.is_pop == 1) {
  254. if (val.store_id && val.userInfo) {
  255. this.can_popup(1)
  256. }
  257. }
  258. // 轮播图弹窗
  259. if (val.systemInfo.set.is_pop == 3) {
  260. if (val.store_id && val.userInfo) {
  261. this.can_popup(3)
  262. }
  263. }
  264. }
  265. },
  266. deep: true,
  267. },
  268. },
  269. onPullDownRefresh() {
  270. this.$store.dispatch('getSystemStup', this.$store.state.store_id);
  271. this.http();
  272. this.$store.commit('SET_REFRESH', false)
  273. setTimeout(() => {
  274. uni.stopPullDownRefresh();
  275. }, 1500)
  276. },
  277. onShareAppMessage(e) {
  278. return {}
  279. },
  280. onHide() {
  281. this.$store.commit('SET_REFRESH', true)
  282. },
  283. onShareAppMessage(e) {
  284. return {}
  285. },
  286. onShareTimeline() {
  287. return {
  288. title: this.systemInfo.title,
  289. imageUrl: this.URL + this.systemInfo.thumb,
  290. }
  291. },
  292. methods: {
  293. ...mapMutations(['SET_COUPON', 'SET_AUDIO', 'SET_SWIPER']),
  294. onBeforeGetCoupon(resultList) {
  295. return this.params
  296. },
  297. initInfo() {
  298. let _this = this;
  299. _this.$http.request('account/getInfo', {
  300. id: _this.userInfo.id,
  301. }, "", "", true).then(res => {
  302. // Set default values for userInfo.nickname and userInfo.avatar
  303. this.userInfo = {
  304. nickname: '微信用户',
  305. avatar: 'https://business.coffunity.cn/upload/default-avatar.jpg'
  306. };
  307. // Only update userInfo.nickname if nickname from server is not empty
  308. if (res.data.nickname && res.data.nickname.trim() !== '') {
  309. this.userInfo.nickname = res.data.nickname;
  310. }
  311. // Only update userInfo.avatar if avatar from server is not 'https://business.coffunity.cn'
  312. if (res.data.avatar && res.data.avatar.trim() !== 'https://business.coffunity.cn') {
  313. this.userInfo.avatar = res.data.avatar;
  314. }
  315. // other code...
  316. }).catch(err => {})
  317. },
  318. onMyFav() {
  319. console.log("myfav");
  320. },
  321. onCloseRenew(e) {
  322. this.$refs.showRenewForm.close();
  323. },
  324. goSchool() {
  325. console.log(112);
  326. uni.navigateTo({
  327. url: '/pages/school/index/index',
  328. })
  329. },
  330. onViewZc(e) {
  331. uni.navigateTo({
  332. url: '/pages/theater/movie/movie?id=' + e.id,
  333. })
  334. },
  335. onViewhd() {
  336. uni.switchTab({
  337. url: '/pages/theater/index/index',
  338. })
  339. },
  340. onVieworder() {
  341. uni.navigateTo({
  342. url: '/pages/myOrderList/myOrderList',
  343. })
  344. },
  345. onViewBind(e) {
  346. uni.navigateTo({
  347. url: '/pages/user-detail/user-detail'
  348. })
  349. },
  350. truncateString(str, maxLength) {
  351. return //str.length > maxLength ? str.substring(0, maxLength)+'...' : str;
  352. },
  353. initVipPackage() {
  354. let _this = this;
  355. _this.$http.request('account/getLevelList', {}, "", "", true).then(res => {
  356. _this.leveList = res.data;
  357. }).catch(err => {})
  358. },
  359. //获取线上影片
  360. getOnLineList() {
  361. let _this = this;
  362. _this.$http.request('zc/home', {}, "", "", true).then(res => {
  363. _this.movieList = res.data;
  364. }).catch(err => {})
  365. },
  366. onOpenWindows() {
  367. uni.navigateTo({
  368. url: '/pages/Center/Center'
  369. })
  370. },
  371. onOpenVip(e) {
  372. this.$refs.vipForm.open('center');
  373. },
  374. //打开收音机
  375. onOpenHw(e) {
  376. this.$refs.hwPopForm.open('center');
  377. },
  378. onOpenRenew(e) {
  379. this.$refs.vipForm.close();
  380. this.$refs.showRenewForm.open("bottom");
  381. },
  382. onShowMoreMenu() {
  383. this.showMoreMenu = !this.showMoreMenu;
  384. },
  385. onOverlayTap() {
  386. this.showMoreMenu = false;
  387. },
  388. onViewCalendar(e) {
  389. uni.navigateTo({
  390. url: '/pages/my-calendar/my-calendar',
  391. })
  392. },
  393. onViewTheater(e) {
  394. uni.switchTab({
  395. url: '/pages/theater/index/index'
  396. })
  397. },
  398. onViewCoffee(e) {
  399. uni.switchTab({
  400. url: '/pages/index/index'
  401. })
  402. },
  403. onViewFitness(e) {
  404. uni.switchTab({
  405. url: '/pages/fitness/index/index'
  406. })
  407. },
  408. onViewSchool(e) {
  409. uni.switchTab({
  410. url: '/pages/school/index/index',
  411. })
  412. },
  413. onViewLibary(e) {
  414. uni.navigateTo({
  415. url: '/pages/school/library/library',
  416. })
  417. },
  418. onViewEquity(e) {
  419. uni.navigateTo({
  420. url: '/pages/equity/equity',
  421. })
  422. },
  423. onViewaddress(e) {
  424. uni.navigateTo({
  425. url: '/pages/address/address',
  426. })
  427. },
  428. // 领券请求 成功调用的事件,领券结果可能成功也可能失败。
  429. onGetCouponSuccess(resultList) {
  430. this.getResultList(resultList);
  431. this.is_coupon = false;
  432. },
  433. onGetCouponFail(result) {
  434. },
  435. // 点击 立即使用 按钮触发的事件,前提是设置了 dialogBtnType 值为 2。
  436. onUseImmediately() {
  437. this.paramsList = [];
  438. uni.switchTab({
  439. url: '/pages/index/index',
  440. })
  441. },
  442. onClose() {
  443. this.paramsList = [];
  444. },
  445. getResultList(resultList) {
  446. let arr = [];
  447. for (let i of resultList) {
  448. arr.push({
  449. activityId: i.activityId,
  450. voucherCode: i.voucherCode
  451. })
  452. }
  453. // console.log(JSON.stringify(arr),"arr")
  454. this.$http.request('oil/successcode', {
  455. activityArr: JSON.stringify(arr),
  456. user_id: this.userInfo.id,
  457. store_id: this.store_id,
  458. }, "", true, true).then(res => {})
  459. },
  460. getCouponList() {
  461. this.$http.request('oil/couponlist', {
  462. store_id: this.store_id,
  463. user_id: this.userInfo.id,
  464. page: 1,
  465. limit: 100,
  466. }, "", true, true).then(res => {
  467. this.paramsList = res.data;
  468. if (res.data.length > 0) {
  469. for (let i of res.data) {
  470. // MERCHANT_UPLOAD 非劵码
  471. // MERCHANT_API 导码
  472. this.params.push({
  473. activityId: i.activity_id,
  474. outBizNo: i.content.out_biz_no,
  475. customizeSendTime: i.content.publish_end_time,
  476. voucherCode: i.voucherCode
  477. })
  478. }
  479. }
  480. // console.log(this.params,"this.params")
  481. })
  482. },
  483. // 是否弹窗
  484. can_popup(type) {
  485. let couponList = [];
  486. this.$http.request('xcx/can_popup', {
  487. store_id: this.store_id,
  488. user_id: this.userInfo.id
  489. }, "", true, true).then(res => {
  490. if (res.code === '200') {
  491. type == 1 ? this.homePop(1) : type == 2 ? this.Coupons() : type == 3 ? this
  492. .homePop(3) :
  493. '';
  494. }
  495. })
  496. },
  497. Coupons() {
  498. let couponList = [];
  499. this.$http.request('xcx/home_pop_up', {
  500. store_id: this.store_id,
  501. user_id: this.userInfo.id
  502. }, "", true, true).then(res => {
  503. for (let s of res.data) {
  504. s.checked = false;
  505. s.state = 1;
  506. if (s.is_index == 1) {
  507. couponList.push(s);
  508. this.SET_COUPON(couponList);
  509. if (couponList.length > 0) {
  510. this.$refs.popup.open();
  511. this.popup_log();
  512. }
  513. }
  514. };
  515. })
  516. },
  517. // 获取语音||轮播图
  518. homePop(type) {
  519. this.$http.request('xcx/home_pop_up', {
  520. store_id: this.store_id,
  521. user_id: this.userInfo.id,
  522. }, "", true, true).then(res => {
  523. if (res.code === '200') {
  524. let arr = res.data;
  525. // console.log(arr, type, "arr")
  526. if (type == 1) {
  527. for (let s of arr) {
  528. s.is_check = 1;
  529. s.pic = getApp().globalData.URL + this.systemInfo.thumb;
  530. s.content = getApp().globalData.URL + s.src;
  531. }
  532. this.SET_AUDIO(arr);
  533. }
  534. if (type == 3) {
  535. this.SET_SWIPER(arr);
  536. }
  537. if (arr.length > 0) {
  538. this.$refs.popup.open();
  539. this.popup_log();
  540. }
  541. }
  542. })
  543. },
  544. popup_log() {
  545. this.$http.request('xcx/popup_log', {
  546. store_id: this.store_id,
  547. user_id: this.userInfo.id,
  548. }, "", true, true).then(res => {
  549. if (res.code === 200) {}
  550. })
  551. },
  552. // 关闭弹窗
  553. removeFn() {
  554. this.$refs.popup.colse();
  555. },
  556. http() {
  557. this.$http.request('template/detail', {
  558. id: this.$store.state.store_id,
  559. controller: 'admin'
  560. }, "", "", true).then(res => {
  561. this.loading = false;
  562. if (res.code === 200) {
  563. if (res.data.detail.template) {
  564. var template = JSON.parse(res.data.detail.template);
  565. // console.log(template, "template")
  566. let game_index = template.findIndex(item => item.isdefault);
  567. // console.log(game_index, "game_index")
  568. this.List = template[game_index];
  569. // console.log(this.List.moduleList[3], "template")
  570. this.is_template = false;
  571. } else {
  572. this.is_template = true;
  573. }
  574. }
  575. })
  576. },
  577. }
  578. }
  579. </script>
  580. <style lang="scss">
  581. @import "./home.scss"
  582. </style>