myhome.vue 15 KB

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