myhome.vue 15 KB

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