index.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813
  1. <template>
  2. <view class="home">
  3. <MyNav title="洲际酒店集团中国西区" bgColor="" :backIcon="false"></MyNav>
  4. <!-- swiper -->
  5. <view class="home-swiper">
  6. <uni-swiper-dot :info="infoList" :current="current1" :mode="mode" :dots-styles="dotsStyles">
  7. <swiper class="swiper-box" @change="change1" circular>
  8. <swiper-item v-for="(item ,index) in infoList" :key="index">
  9. <view class="swiper-item" v-if="item.resource_type == 1" @click="$utils.jump({
  10. jump_type: item.jump_type,
  11. jump_config: item.jump_config
  12. })">
  13. <image style="width: 100%;height:592rpx;" :src="item.img" mode="aspectFill"></image>
  14. </view>
  15. <view class="swiper-item" v-if="item.resource_type == 2">
  16. <video :id="`myVideo${index}`" ref="swiperVideo" style="width: 100%; height: 592rpx;"
  17. :src="item.video_url" controls :enable-progress-gesture="false">
  18. </video>
  19. </view>
  20. </swiper-item>
  21. </swiper>
  22. </uni-swiper-dot>
  23. </view>
  24. <!-- 金刚图 -->
  25. <view class="home-nav">
  26. <view class="home-nav-item" v-for="(item,index) in navList" :key="index" @click="$utils.jump({
  27. jump_type: item.jump_type,
  28. jump_config: item.jump_config
  29. })">
  30. <image style="width: 101.96rpx;height: 103.96rpx;" :src="item.img" mode=""></image>
  31. <text style="color: #333;font-size: 24rpx;margin-top: 18rpx; ">{{item.title}}</text>
  32. </view>
  33. </view>
  34. <!-- 活动专区 -->
  35. <view class="home-special-area">
  36. <view class="home-special-area-left">
  37. <text>非凡西区</text>
  38. <view class="text-shadow"></view>
  39. <image style="width:16rpx;height: 16rpx;margin-left: 14rpx;" src="/static/icon/symbol.png" mode="">
  40. </image>
  41. </view>
  42. <view @click="goSpecialList" class="home-special-area-right">
  43. <text>全部</text>
  44. <image style="width: 12rpx; height: 20rpx;margin-left: 8rpx;" src="/static/icon/right01.png" mode="">
  45. </image>
  46. </view>
  47. </view>
  48. <!-- 活动图片 -->
  49. <view class="home-special-img">
  50. <template v-for="(item,index) in specialList">
  51. <view class="ListItem" v-if="item.show_status" :key="index" @click="$utils.jump({
  52. jump_type: 3,
  53. jump_config: '/pages/index/active-detail/index',
  54. id: item.id,
  55. })">
  56. <image style="width: 312rpx;height: 200rpx; border-radius: 12rpx; "
  57. :src="item.banners?item.cover_img:'http://t9.9026.com/imgs/Kudosbg.png'" mode=""></image>
  58. <view class="kudosicon" @click.stop="kudosActive(item.id,index)">
  59. <image style="width:24rpx;height: 24rpx;" src="/static/icon/Kudos.png" v-if="item.is_like==0">
  60. </image>
  61. <image style="width:24rpx;height: 24rpx;" src="/static/icon/Kudos(1).png"
  62. v-if="item.is_like==1">
  63. </image>
  64. </view>
  65. <text style="color: #333;font-weight: bold;font-size: 28rpx;">{{item.title}}</text>
  66. </view>
  67. </template>
  68. </view>
  69. <!-- 广告图 -->
  70. <view class="home-banner" v-if="!isShowAdver && in_page ==1">
  71. <view class="home-banner-img" v-if="in_page==1 && type == 1 ">
  72. <image style="width: 100%; height: 576rpx; border-radius: 12rpx;" :src="advData.img" mode="" @click="$utils.jump({
  73. jump_type: advData.jump_type,
  74. jump_config: advData.jump_config
  75. })"></image>
  76. <image @click="cleanCoverImg" class="img-clean" style="width: 20rpx; height: 20rpx; "
  77. src="/static/icon/clean.png" mode="">
  78. </image>
  79. </view>
  80. <view class="home-banner-img" v-if="in_page==1 && type == 2">
  81. <image class="banner-img" v-if="!isOpenVideo" @click="openVideoPlay"
  82. style="width: 100%; height: 576rpx; border-radius: 12rpx;" :src="videoCoverImg" mode=""></image>
  83. <image @click="cleanCoverImg" class="img-clean" style="width: 20rpx; height: 20rpx; "
  84. src="/static/icon/clean.png" mode="">
  85. </image>
  86. <video class="baner-video" id="myVideo" ref="myVideo"
  87. style="width: 100%; height: 576rpx;border-radius: 12rpx; " :src="videoSrc" controls
  88. :enable-progress-gesture="false">
  89. </video>
  90. </view>
  91. </view>
  92. <movable-area class="movableArea">
  93. <movable-view class="movableView" direction="all" x="630rpx" y="700rpx">
  94. <view class="img-IHg" @click="goJoin()">
  95. <image style="width: 84rpx; height: 84rpx;border-radius: 50%;" :src="indexVipImg" mode=""></image>
  96. </view>
  97. </movable-view>
  98. </movable-area>
  99. <!-- 广告的附图 -->
  100. <view v-if="advertisInsetImg" class="home-attach" @click="$utils.jump({
  101. jump_type: advInsetImg.jump_type,
  102. jump_config: advInsetImg.jump_config
  103. })">
  104. <image style="width: 690rpx;height: 156rpx;border-radius: 79rpx;" :src="advInsetImg.img" mode=""></image>
  105. </view>
  106. <!-- 酒店推荐 -->
  107. <view class="home-hotel home-special-area">
  108. <view class="home-special-area-left">
  109. <text>西区优品</text>
  110. <view class="text-shadow"></view>
  111. <image style="width:16rpx;height: 16rpx;margin-left: 14rpx;" src="/static/icon/symbol.png" mode="">
  112. </image>
  113. </view>
  114. </view>
  115. <!-- 酒店推荐图片 -->
  116. <view class="home-hotel-img">
  117. <view class="home-hotel-img-content">
  118. <template v-for="(item,index) in goodsList">
  119. <view v-if="item.status==1" class="home-hotel-img-content-item" :key="index"
  120. :style="{marginTop:item.marginTop || 0 }" @click="goToProduct(item.id)">
  121. <image class="home-hotel-img-content-item-img"
  122. :class="item.short?'home-hotel-img-content-item-img': 'home-hotel-img-content-item-img-long' "
  123. :src="item.cover_img" mode=""></image>
  124. <view class="text">
  125. <text class="text-top">{{item.name}}</text>
  126. </view>
  127. </view>
  128. </template>
  129. </view>
  130. <view class="home-hotel-img-more" @click='geMore'>
  131. <text>查看更多商品</text>
  132. </view>
  133. </view>
  134. <!-- 酒店品牌 -->
  135. <view class="home-brand home-special-area">
  136. <view class="home-special-area-left">
  137. <text>洲际酒店集团品牌</text>
  138. <view class="text-shadow"></view>
  139. <image style="width:16rpx;height: 16rpx;margin-left: 14rpx;" src="/static/icon/symbol.png" mode="">
  140. </image>
  141. </view>
  142. </view>
  143. <!-- 酒店品牌图片 -->
  144. <view class="home-brand-img">
  145. <uni-swiper-dot :info="info" mode="default" :current="current2" :dots-styles="dotsStylesBand">
  146. <swiper class="swiper-box" circular @change="change2">
  147. <swiper-item v-for="(items ,index) in info" :key="index">
  148. <view v-for="(item ,j) in items" :key="j" class="swiper-item" @click="$utils.jump({
  149. jump_type: item.jump_type,
  150. jump_config: item.jump_config
  151. })">
  152. <image style="width:144rpx;height:142rpx;" :src="item.img" mode="aspectFill"></image>
  153. </view>
  154. </swiper-item>
  155. </swiper>
  156. </uni-swiper-dot>
  157. </view>
  158. <!-- 触底 -->
  159. <view class="home-bottom">
  160. <uni-load-more :status="status" color="#CCCCCC" :content-text="contentText" />
  161. </view>
  162. <!-- 弹窗广告 -->
  163. <uni-popup ref="popup" type="center">
  164. <view class="popup-banner">
  165. <image @click="$utils.jump({
  166. jump_type: popupData.jump_type,
  167. jump_config: popupData.jump_config
  168. })" style="width: 656rpx;height: 916rpx;border-radius: 12rpx;" :src="popupData.img">
  169. </image>
  170. <view class="popup-banner-clean" @click='closePopupBanner'>
  171. <image style="width: 20rpx; height: 20rpx; " src="/static/icon/clean.png" mode="">
  172. </view>
  173. </view>
  174. </uni-popup>
  175. <view style="height:168rpx; background-color: #f9f9f9; "></view>
  176. <tab-bar></tab-bar>
  177. </view>
  178. </template>
  179. <script>
  180. import TabBar from '../../components/TabBar/tabbar.vue'
  181. import MyNav from "@/components/my-nav/my-nav.vue"
  182. export default {
  183. components: {
  184. TabBar,
  185. MyNav
  186. },
  187. data() {
  188. return {
  189. //vip图标
  190. indexVipImg:'',
  191. //加入会员跳转
  192. adviseVip: '',
  193. jump_type_vip: '',
  194. jump_config_vip: {},
  195. //用户个人信息,判断是否登录
  196. admin: '',
  197. //获取token
  198. data: {},
  199. //录播图是展示视频1:图片2:视频
  200. resource_type: '',
  201. //广告弹框跳转
  202. jup_type: '',
  203. jump_config: '',
  204. //广告弹框图
  205. popupData: {},
  206. //弹窗的类型 1只弹一次首次 2就是每次都弹啊
  207. times_type: '',
  208. //弹窗的显示0不显示 1显示
  209. popupImgStatus: '',
  210. //视频封面图
  211. isOpenVideo: false,
  212. videoCoverImg: '',
  213. videoSrc: '',
  214. in_page: '',
  215. type: '',
  216. //隐藏广告图
  217. isShowAdver: false,
  218. //广告图
  219. advertis: '',
  220. advData: {},
  221. //广告附图展示图片
  222. advertisInsetImg: '',
  223. advInsetImg: {},
  224. //广告图展示图片:
  225. advertisImg: '',
  226. //广告图展示视频
  227. goodsList: [{
  228. cover_img: 'https://t9.9026.com/imgs/11.png',
  229. name: '2023新春福兔系列礼盒 倾心甄选 待你拥有'
  230. },
  231. {
  232. cover_img: 'https://t9.9026.com/imgs/22.png',
  233. name: '2023新春福兔系列礼盒 倾心甄选 待你拥有'
  234. },
  235. {
  236. cover_img: 'https://t9.9026.com/imgs/33.png',
  237. name: '2023新春福兔系列礼盒 倾心甄选 待你拥有'
  238. },
  239. {
  240. cover_img: 'https://t9.9026.com/imgs/44.png',
  241. name: '2023新春福兔系列礼盒 倾心甄选 待你拥有'
  242. },
  243. ],
  244. status: 'noMore',
  245. contentText: {
  246. contentdown: '查看更多',
  247. contentrefresh: '加载中',
  248. contentnomore: '—— 已经到底啦 ——'
  249. },
  250. infoList: [],
  251. //轮播图
  252. info: [],
  253. dotsStyles: {
  254. bottom: 24,
  255. backgroundColor: 'rgba(255, 255, 255, .3)',
  256. border: '1px rgba(255, 255, 255, .3) solid',
  257. color: '#fff',
  258. selectedBackgroundColor: 'rgba(255, 255, 255, 1)',
  259. selectedBorder: '1px rgba(255, 255, 255, 1) solid'
  260. },
  261. dotsStylesBand: {
  262. bottom: -24,
  263. backgroundColor: 'rgba(198, 198, 198, 1)',
  264. border: '1px rgba(0, 0, 0, .3) solid',
  265. color: '#fff',
  266. selectedBackgroundColor: 'rgba(151, 151, 151, 1)',
  267. selectedBorder: '1px rgba(0, 0, 0, .9) solid'
  268. },
  269. //指示点显示位置
  270. current1: 0,
  271. current2: 0,
  272. //指示点模式
  273. mode: 'dot',
  274. // 金刚图
  275. navList: [],
  276. //活动专区
  277. specialList: [],
  278. isDevelopment: false,
  279. }
  280. },
  281. onTabItemTap(e) {
  282. console.log(e)
  283. },
  284. // 下拉刷新
  285. onPullDownRefresh() {
  286. setTimeout(() => {
  287. uni.stopPullDownRefresh();
  288. this.$store.dispatch('user/allset', null)
  289. this.getAllSet()
  290. this.getList()
  291. }, 1000);
  292. },
  293. onReady: function(res) {
  294. this.videoContext = uni.createVideoContext('myVideo')
  295. },
  296. onShow() {
  297. //获取token
  298. this.getmsg()
  299. this.admin = this.$store.getters.userInfo
  300. },
  301. onLoad() {
  302. this.getGoodsList()
  303. this.getAllSet()
  304. // this.isDevelopment = process.env.NODE_ENV === 'development';
  305. this.isDevelopment = true;
  306. this.playVideo(this.current1)
  307. uni.$on('refreshActivityList',()=>{
  308. this.getList()
  309. })
  310. },
  311. // 监听判断视频的播放与暂停
  312. watch: {
  313. current1: {
  314. handler(newName, oldName) {
  315. console.log(newName, oldName);
  316. const id = `myVideo${oldName}`
  317. this.currentVideo = uni.createVideoContext(id, this)
  318. this.$nextTick(() => {
  319. if (oldName != newName) {
  320. this.stopVideo(oldName)
  321. } else {
  322. this.playVideo(newName)
  323. }
  324. })
  325. },
  326. immediate: true,
  327. deep: true
  328. }
  329. },
  330. methods: {
  331. // **************** Data ***************//
  332. // 切换轮播图指示点
  333. change1(e) {
  334. this.current1 = e.detail.current;
  335. this.playVideo(this.current1)
  336. },
  337. // 播放视频
  338. playVideo(index) {
  339. console.log(111);
  340. this.$nextTick(() => {
  341. const id = `myVideo${index}`
  342. this.currentVideo = uni.createVideoContext(id, this)
  343. this.currentVideo.play()
  344. })
  345. },
  346. // 停止播放视频
  347. stopVideo(index) {
  348. this.$nextTick(() => {
  349. const id = `myVideo${index}`
  350. this.currentVideo = uni.createVideoContext(id, this)
  351. this.currentVideo.stop()
  352. })
  353. },
  354. //获取配置数据
  355. getAllSet() {
  356. this.$api.document.allSet().then(res => {
  357. this.$store.dispatch('user/allset', res.data)
  358. this.infoList = this.$store.getters.allset.banners
  359. this.navList = this.$store.getters.allset.nav_icon
  360. this.info = this.$store.getters.allset.partner
  361. //广告图
  362. this.advertis = this.$store.getters.allset.advertises.filter(item => {
  363. return item.in_page == 1
  364. })
  365. this.advData = this.advertis[0];
  366. if(this.advData){
  367. if (this.advertis[0].type == 1) {
  368. this.in_page = 1
  369. this.type = 1
  370. this.advertisImg = this.advertis[0].img
  371. } else if (this.advertis[0].type == 2) {
  372. this.in_page = 1
  373. this.type = 2
  374. this.videoCoverImg = this.advertis[0].video_cover
  375. this.videoSrc = this.advertis[0].video
  376. }
  377. }
  378. //胶囊图
  379. this.advertisInset = this.$store.getters.allset.advertises.filter(item => {
  380. return item.in_page == 2
  381. })
  382. if(this.advertisInset[0]){
  383. this.advInsetImg = this.advertisInset[0]
  384. this.advertisInsetImg = this.advertisInset[0].img
  385. }
  386. //广告弹框图
  387. this.popupData = this.$store.getters.allset.popup_ads[0]
  388. //弹窗是否展示
  389. this.popupImgStatus = this.popupData?.status
  390. this.times_type = this.popupData?.times_type
  391. //广告弹框跳转h5和小程序和内部
  392. this.jump_type = this.popupData?.jump_type,
  393. this.jump_config = this.popupData?.jump_config
  394. this.open()
  395. //加入vip跳转
  396. this.adviseVip = this.$store.getters.allset.add_member
  397. //vip图标
  398. this.indexVipImg = this.adviseVip.value.index_page
  399. this.jump_type_vip = this.adviseVip.value.index_jump_type
  400. if (this.jump_type_vip == 1) {
  401. this.jump_config_vip = this.adviseVip.value.index_h5_url
  402. } else if (this.jump_type_vip == 2) {
  403. this.jump_config_vip.appid = this.adviseVip.value.index_appid
  404. this.jump_config_vip.path = this.adviseVip.value.index_path
  405. } else if (this.jump_type_vip == 3) {
  406. this.jump_config_vip = this.adviseVip.value.index_other_path
  407. }
  408. })
  409. },
  410. // 获取活动列表
  411. getList() {
  412. this.$api.active.getActiveList({
  413. page: 0,
  414. keyword: '',
  415. category_id: ''
  416. }).then(res => {
  417. console.log(res, '活动列表')
  418. if (res.code == 0) {
  419. this.specialList = res.data.data
  420. }
  421. })
  422. },
  423. //产品列表type:1,第三方购买产品
  424. getGoodsList(category_id) {
  425. this.$api.product.getProducts({
  426. type: 1,
  427. page: 0,
  428. }).then(res => {
  429. this.goodsList = res.data.data.slice(0, 4)
  430. this.shortLong()
  431. console.log(this.goodsList, '------>产品图');
  432. })
  433. },
  434. //产品详情
  435. produceDetail(id) {
  436. uni.navigateTo({
  437. url: `/pages/goods/goods-detail/index?id=${id}&type=1`
  438. })
  439. },
  440. // **************** Dev ***************//
  441. shortLong() {
  442. this.goodsList.forEach((item, index, arr) => {
  443. if (index % 4 === 0) {
  444. item.short = true
  445. }
  446. if (index % 4 === 1) {
  447. item.long = true
  448. }
  449. if (index % 4 === 2) {
  450. item.long = true
  451. item.marginTop = -68 + "rpx"
  452. }
  453. if (index % 4 === 3) {
  454. item.short = true
  455. }
  456. })
  457. },
  458. //隐藏图片
  459. cleanCoverImg() {
  460. this.isShowAdver = !this.isShowAdver
  461. },
  462. //打开弹框
  463. open() {
  464. console.log(this.popupImgStatus, this.times_type);
  465. // 从本地缓存中同步获取指定 key 对应的内容,用于判断是否是第一次打开应用
  466. if (this.popupImgStatus == 1) {
  467. if (this.times_type == 1) {
  468. //首次进入弹窗
  469. const value = uni.getStorageSync('launchFlag');
  470. if (value) {
  471. console.log('首次弹窗')
  472. } else {
  473. // 没有值,跳到引导页,并存储,下次打开就不会进去引导页
  474. uni.setStorage({
  475. key: 'launchFlag',
  476. data: true
  477. });
  478. this.$refs.popup.open('center')
  479. }
  480. } else {
  481. this.$refs.popup.open('center') //每次都弹
  482. }
  483. } else {
  484. this.$refs.popup.close() //不显示广告弹框
  485. }
  486. },
  487. //关闭弹框
  488. closePopupBanner() {
  489. this.$refs.popup.close()
  490. },
  491. //点击视频封面图片,播放视频
  492. openVideoPlay() {
  493. this.isOpenVideo = !this.isOpenVideo
  494. this.videoContext.play()
  495. },
  496. // **************** 跳转 ***************//
  497. //合同伙伴跳转h5和小程序
  498. goGoodsDetail(id, urls) {
  499. console.log(urls, '----->url');
  500. if (id == 1) {
  501. const url = urls; // 跳转的外链
  502. const navtitle = 'H5'; // 这个标题是你自己可以设置的
  503. uni.navigateTo({
  504. // 跳转到webview页面
  505. url: `/pages/webview/webview?url=${url}&nav=${navtitle}`,
  506. success: () => {
  507. console.log('成功')
  508. },
  509. fail: (e) => {
  510. console.log(e, "失败")
  511. }
  512. });
  513. } else if (id == 2) {
  514. let obj = JSON.parse(urls);
  515. wx.navigateToMiniProgram({
  516. appId: `${obj.appid}`, //appid
  517. path: `${obj.path}`, //path
  518. extraData: { //参数
  519. foo: 'bar'
  520. },
  521. // envVersion: 'develop', //开发版develop 开发版 trial 体验版 release 正式版
  522. success(res) {
  523. console.log('成功')
  524. // 打开成功
  525. },
  526. fail(e) {
  527. console.log(e, '失败')
  528. }
  529. })
  530. }
  531. },
  532. // 活动详情页
  533. activeDetail(id) {
  534. uni.navigateTo({
  535. url: '/pages/index/active-detail/index?id=' + id
  536. })
  537. },
  538. // 点赞活动
  539. kudosActive(id, index) {
  540. let beforeLike = this.specialList[index].is_like
  541. this.$api.active.kudos({
  542. activity_id: id
  543. }).then(res => {
  544. console.log(res, '点赞')
  545. if (res.code == 0) {
  546. if (beforeLike == 1) {
  547. this.specialList[index].is_like = 0
  548. uni.showToast({
  549. icon: 'none',
  550. title: '取消点赞'
  551. })
  552. } else {
  553. this.specialList[index].is_like = 1
  554. uni.showToast({
  555. icon: 'none',
  556. title: '点赞成功'
  557. })
  558. }
  559. }
  560. })
  561. },
  562. //获取当前页面路径
  563. getPageUrl() {
  564. const pages = getCurrentPages();
  565. console.log(pages, '--------->pages')
  566. if (pages.length == 1) {
  567. const currentPage = pages[0];
  568. let pageUrl = `/${currentPage.route}`;
  569. return pageUrl
  570. console.log('当前页面url:', pageUrl);
  571. } else {
  572. const currentPage = pages[pages.length - 1];
  573. let pageUrl = `/${currentPage.route}`;
  574. return pageUrl
  575. console.log('当前页面url:', pageUrl);
  576. }
  577. },
  578. // 跳转其他小程序
  579. goJoin() {
  580. let _this = this
  581. this.jumpHAppID(this.jump_type_vip, this.jump_config_vip)
  582. },
  583. // 跳转其他小程序
  584. jumpHAppID(id, urls) {
  585. if (id == 1) {
  586. const url = urls; // 跳转的外链
  587. const navtitle = 'H5'; // 这个标题是你自己可以设置的
  588. uni.navigateTo({
  589. // 跳转到webview页面
  590. url: `/pages/webview/webview?url=${url}&nav=${navtitle}`,
  591. success: () => {
  592. console.log('成功')
  593. },
  594. fail: (e) => {
  595. console.log(e, "失败")
  596. }
  597. });
  598. } else if (id == 2) {
  599. let _this = this
  600. let obj = urls;
  601. console.log(obj, '----->obj');
  602. wx.navigateToMiniProgram({
  603. appId: `${obj.appid}`, //appid
  604. path: `${obj.path}`, //path
  605. extraData: { //参数
  606. foo: 'bar'
  607. },
  608. // envVersion: 'develop', //开发版develop 开发版 trial 体验版 release 正式版
  609. success(res) {
  610. let page = _this.getPageUrl()
  611. let user_id = ''
  612. if (_this.admin != null) {
  613. user_id = _this.admin.id
  614. } else {
  615. user_id = 0
  616. }
  617. _this.$api.my.userMemberAdd({
  618. user_id,
  619. page,
  620. }).then(res => {
  621. console.log(res.data);
  622. })
  623. // 打开成功
  624. },
  625. fail(e) {
  626. console.log(e, '失败')
  627. }
  628. })
  629. } else if (id == 3) {
  630. uni.redirectTo({
  631. url: urls,
  632. fail: (err) => {
  633. uni.reLaunch({
  634. url: urls
  635. })
  636. }
  637. })
  638. }
  639. },
  640. //用户访问
  641. getUserVisits() {
  642. this.$api.my.userVisits({
  643. page: '/pages/index/index'
  644. }).then(res => {
  645. console.log(res.data);
  646. })
  647. },
  648. //跳转方法
  649. // jumpHAppID(id, urls) {
  650. // if (id == 1) {
  651. // const url = urls; // 跳转的外链
  652. // const navtitle = 'H5'; // 这个标题是你自己可以设置的
  653. // uni.navigateTo({
  654. // // 跳转到webview页面
  655. // url: `/pages/webview/webview?url=${url}&nav=${navtitle}`,
  656. // success: () => {
  657. // console.log('成功')
  658. // },
  659. // fail: (e) => {
  660. // console.log(e, "失败")
  661. // }
  662. // });
  663. // } else if (id == 2) {
  664. // let obj = JSON.parse(urls);
  665. // wx.navigateToMiniProgram({
  666. // appId: `${obj.appid}`, //appid
  667. // path: `${obj.path}`, //path
  668. // extraData: { //参数
  669. // foo: 'bar'
  670. // },
  671. // // envVersion: 'develop', //开发版develop 开发版 trial 体验版 release 正式版
  672. // success(res) {
  673. // console.log('成功')
  674. // // 打开成功
  675. // },
  676. // fail(e) {
  677. // console.log(e, '失败')
  678. // }
  679. // })
  680. // } else if (id == 3) {
  681. // uni.redirectTo({
  682. // url: urls,
  683. // fail:(err)=>{
  684. // uni.reLaunch({
  685. // url: urls
  686. // })
  687. // }
  688. // })
  689. // }
  690. // },
  691. //查看更多商品
  692. geMore() {
  693. if (this.admin == undefined) {
  694. uni.navigateTo({
  695. url: '/pages/login/login'
  696. })
  697. } else {
  698. uni.navigateTo({
  699. url: '/pages/goods/goods'
  700. })
  701. }
  702. },
  703. //跳转产品详情
  704. goToProduct(id) {
  705. if (this.admin == undefined) {
  706. uni.navigateTo({
  707. url: '/pages/login/login'
  708. })
  709. } else {
  710. uni.navigateTo({
  711. url: `/pages/goods/goods-detail/index?id=${id}&type=1`
  712. })
  713. }
  714. },
  715. //产品列表
  716. goProduceList() {
  717. uni.navigateTo({
  718. url: '/pages/goods/goods'
  719. })
  720. },
  721. //活动列表
  722. goSpecialList() {
  723. uni.navigateTo({
  724. url: '/pages/index/active-list/index'
  725. })
  726. },
  727. change2(e) {
  728. this.current2 = e.detail.current;
  729. },
  730. getCode() {
  731. return new Promise((resolve, reject) => {
  732. uni.getUserInfo({
  733. success: loginRes => {
  734. console.log(loginRes);
  735. this.data.encryptData = loginRes.encryptedData,
  736. this.data.iv = loginRes.iv
  737. resolve(this.data)
  738. }
  739. })
  740. })
  741. },
  742. //获取微信登录的code码
  743. getmsg() {
  744. uni.login({
  745. provider: uni.$u.platform,
  746. success: res => {
  747. console.log(res, '------->res');
  748. this.getCode().then((data) => {
  749. console.log(this.data, '------>data');
  750. const params = {
  751. code: res.code,
  752. iv: data.iv,
  753. encryptData: data.encryptData
  754. }
  755. console.log(params);
  756. this.$api.my.myLogin(params).then(res => {
  757. if (res.code == 0) {
  758. let {
  759. token
  760. } = res.data
  761. this.$store.dispatch('user/token', token)
  762. // 获取活动列表
  763. this.getList()
  764. //用户访问
  765. this.getUserVisits()
  766. } else {
  767. uni.showToast({
  768. icon: 'none',
  769. title: res.msg
  770. })
  771. }
  772. })
  773. })
  774. }
  775. })
  776. }
  777. },
  778. }
  779. </script>
  780. <style lang="scss" src="./index.scss" scoped></style>