index.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810
  1. <template>
  2. <view class="home">
  3. <MyNav title="洲际酒店集团中国西区" bgColor="" :backIcon="true"></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: 64rpx; height: 58rpx;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. },
  308. // 监听判断视频的播放与暂停
  309. watch: {
  310. current1: {
  311. handler(newName, oldName) {
  312. console.log(newName, oldName);
  313. const id = `myVideo${oldName}`
  314. this.currentVideo = uni.createVideoContext(id, this)
  315. this.$nextTick(() => {
  316. if (oldName != newName) {
  317. this.stopVideo(oldName)
  318. } else {
  319. this.playVideo(newName)
  320. }
  321. })
  322. },
  323. immediate: true,
  324. deep: true
  325. }
  326. },
  327. methods: {
  328. // **************** Data ***************//
  329. // 切换轮播图指示点
  330. change1(e) {
  331. this.current1 = e.detail.current;
  332. this.playVideo(this.current1)
  333. },
  334. // 播放视频
  335. playVideo(index) {
  336. console.log(111);
  337. this.$nextTick(() => {
  338. const id = `myVideo${index}`
  339. this.currentVideo = uni.createVideoContext(id, this)
  340. this.currentVideo.play()
  341. })
  342. },
  343. // 停止播放视频
  344. stopVideo(index) {
  345. this.$nextTick(() => {
  346. const id = `myVideo${index}`
  347. this.currentVideo = uni.createVideoContext(id, this)
  348. this.currentVideo.stop()
  349. })
  350. },
  351. //获取配置数据
  352. getAllSet() {
  353. this.$api.document.allSet().then(res => {
  354. this.$store.dispatch('user/allset', res.data)
  355. this.infoList = this.$store.getters.allset.banners
  356. this.navList = this.$store.getters.allset.nav_icon
  357. this.info = this.$store.getters.allset.partner
  358. //广告图
  359. this.advertis = this.$store.getters.allset.advertises.filter(item => {
  360. return item.in_page == 1
  361. })
  362. this.advData = this.advertis[0];
  363. if(this.advData){
  364. if (this.advertis[0].type == 1) {
  365. this.in_page = 1
  366. this.type = 1
  367. this.advertisImg = this.advertis[0].img
  368. } else if (this.advertis[0].type == 2) {
  369. this.in_page = 1
  370. this.type = 2
  371. this.videoCoverImg = this.advertis[0].video_cover
  372. this.videoSrc = this.advertis[0].video
  373. }
  374. }
  375. //胶囊图
  376. this.advertisInset = this.$store.getters.allset.advertises.filter(item => {
  377. return item.in_page == 2
  378. })
  379. if(this.advertisInset[0]){
  380. this.advInsetImg = this.advertisInset[0]
  381. this.advertisInsetImg = this.advertisInset[0].img
  382. }
  383. //广告弹框图
  384. this.popupData = this.$store.getters.allset.popup_ads[0]
  385. //弹窗是否展示
  386. this.popupImgStatus = this.popupData?.status
  387. this.times_type = this.popupData?.times_type
  388. //广告弹框跳转h5和小程序和内部
  389. this.jump_type = this.popupData?.jump_type,
  390. this.jump_config = this.popupData?.jump_config
  391. this.open()
  392. //加入vip跳转
  393. this.adviseVip = this.$store.getters.allset.add_member
  394. //vip图标
  395. this.indexVipImg = this.adviseVip.value.index_page
  396. this.jump_type_vip = this.adviseVip.value.index_jump_type
  397. if (this.jump_type_vip == 1) {
  398. this.jump_config_vip = this.adviseVip.value.index_h5_url
  399. } else if (this.jump_type_vip == 2) {
  400. this.jump_config_vip.appid = this.adviseVip.value.index_appid
  401. this.jump_config_vip.path = this.adviseVip.value.index_path
  402. } else if (this.jump_type_vip == 3) {
  403. this.jump_config_vip = this.adviseVip.value.index_other_path
  404. }
  405. })
  406. },
  407. // 获取活动列表
  408. getList() {
  409. this.$api.active.getActiveList({
  410. page: 0,
  411. keyword: '',
  412. category_id: ''
  413. }).then(res => {
  414. console.log(res, '活动列表')
  415. if (res.code == 0) {
  416. this.specialList = res.data.data
  417. }
  418. })
  419. },
  420. //产品列表type:1,第三方购买产品
  421. getGoodsList(category_id) {
  422. this.$api.product.getProducts({
  423. type: 1,
  424. page: 0,
  425. }).then(res => {
  426. this.goodsList = res.data.data.slice(0, 4)
  427. this.shortLong()
  428. console.log(this.goodsList, '------>产品图');
  429. })
  430. },
  431. //产品详情
  432. produceDetail(id) {
  433. uni.navigateTo({
  434. url: `/pages/goods/goods-detail/index?id=${id}&type=1`
  435. })
  436. },
  437. // **************** Dev ***************//
  438. shortLong() {
  439. this.goodsList.forEach((item, index, arr) => {
  440. if (index % 4 === 0) {
  441. item.short = true
  442. }
  443. if (index % 4 === 1) {
  444. item.long = true
  445. }
  446. if (index % 4 === 2) {
  447. item.long = true
  448. item.marginTop = -68 + "rpx"
  449. }
  450. if (index % 4 === 3) {
  451. item.short = true
  452. }
  453. })
  454. },
  455. //隐藏图片
  456. cleanCoverImg() {
  457. this.isShowAdver = !this.isShowAdver
  458. },
  459. //打开弹框
  460. open() {
  461. console.log(this.popupImgStatus, this.times_type);
  462. // 从本地缓存中同步获取指定 key 对应的内容,用于判断是否是第一次打开应用
  463. if (this.popupImgStatus == 1) {
  464. if (this.times_type == 1) {
  465. //首次进入弹窗
  466. const value = uni.getStorageSync('launchFlag');
  467. if (value) {
  468. console.log('首次弹窗')
  469. } else {
  470. // 没有值,跳到引导页,并存储,下次打开就不会进去引导页
  471. uni.setStorage({
  472. key: 'launchFlag',
  473. data: true
  474. });
  475. this.$refs.popup.open('center')
  476. }
  477. } else {
  478. this.$refs.popup.open('center') //每次都弹
  479. }
  480. } else {
  481. this.$refs.popup.close() //不显示广告弹框
  482. }
  483. },
  484. //关闭弹框
  485. closePopupBanner() {
  486. this.$refs.popup.close()
  487. },
  488. //点击视频封面图片,播放视频
  489. openVideoPlay() {
  490. this.isOpenVideo = !this.isOpenVideo
  491. this.videoContext.play()
  492. },
  493. // **************** 跳转 ***************//
  494. //合同伙伴跳转h5和小程序
  495. goGoodsDetail(id, urls) {
  496. console.log(urls, '----->url');
  497. if (id == 1) {
  498. const url = urls; // 跳转的外链
  499. const navtitle = 'H5'; // 这个标题是你自己可以设置的
  500. uni.navigateTo({
  501. // 跳转到webview页面
  502. url: `/pages/webview/webview?url=${url}&nav=${navtitle}`,
  503. success: () => {
  504. console.log('成功')
  505. },
  506. fail: (e) => {
  507. console.log(e, "失败")
  508. }
  509. });
  510. } else if (id == 2) {
  511. let obj = JSON.parse(urls);
  512. wx.navigateToMiniProgram({
  513. appId: `${obj.appid}`, //appid
  514. path: `${obj.path}`, //path
  515. extraData: { //参数
  516. foo: 'bar'
  517. },
  518. // envVersion: 'develop', //开发版develop 开发版 trial 体验版 release 正式版
  519. success(res) {
  520. console.log('成功')
  521. // 打开成功
  522. },
  523. fail(e) {
  524. console.log(e, '失败')
  525. }
  526. })
  527. }
  528. },
  529. // 活动详情页
  530. activeDetail(id) {
  531. uni.navigateTo({
  532. url: '/pages/index/active-detail/index?id=' + id
  533. })
  534. },
  535. // 点赞活动
  536. kudosActive(id, index) {
  537. let beforeLike = this.specialList[index].is_like
  538. this.$api.active.kudos({
  539. activity_id: id
  540. }).then(res => {
  541. console.log(res, '点赞')
  542. if (res.code == 0) {
  543. if (beforeLike == 1) {
  544. this.specialList[index].is_like = 0
  545. uni.showToast({
  546. icon: 'none',
  547. title: '取消点赞'
  548. })
  549. } else {
  550. this.specialList[index].is_like = 1
  551. uni.showToast({
  552. icon: 'none',
  553. title: '点赞成功'
  554. })
  555. }
  556. }
  557. })
  558. },
  559. //获取当前页面路径
  560. getPageUrl() {
  561. const pages = getCurrentPages();
  562. console.log(pages, '--------->pages')
  563. if (pages.length == 1) {
  564. const currentPage = pages[0];
  565. let pageUrl = `/${currentPage.route}`;
  566. return pageUrl
  567. console.log('当前页面url:', pageUrl);
  568. } else {
  569. const currentPage = pages[pages.length - 1];
  570. let pageUrl = `/${currentPage.route}`;
  571. return pageUrl
  572. console.log('当前页面url:', pageUrl);
  573. }
  574. },
  575. // 跳转其他小程序
  576. goJoin() {
  577. let _this = this
  578. this.jumpHAppID(this.jump_type_vip, this.jump_config_vip)
  579. },
  580. // 跳转其他小程序
  581. jumpHAppID(id, urls) {
  582. if (id == 1) {
  583. const url = urls; // 跳转的外链
  584. const navtitle = 'H5'; // 这个标题是你自己可以设置的
  585. uni.navigateTo({
  586. // 跳转到webview页面
  587. url: `/pages/webview/webview?url=${url}&nav=${navtitle}`,
  588. success: () => {
  589. console.log('成功')
  590. },
  591. fail: (e) => {
  592. console.log(e, "失败")
  593. }
  594. });
  595. } else if (id == 2) {
  596. let _this = this
  597. let obj = urls;
  598. console.log(obj, '----->obj');
  599. wx.navigateToMiniProgram({
  600. appId: `${obj.appid}`, //appid
  601. path: `${obj.path}`, //path
  602. extraData: { //参数
  603. foo: 'bar'
  604. },
  605. // envVersion: 'develop', //开发版develop 开发版 trial 体验版 release 正式版
  606. success(res) {
  607. let page = _this.getPageUrl()
  608. let user_id = ''
  609. if (_this.admin != null) {
  610. user_id = _this.admin.id
  611. } else {
  612. user_id = 0
  613. }
  614. _this.$api.my.userMemberAdd({
  615. user_id,
  616. page,
  617. }).then(res => {
  618. console.log(res.data);
  619. })
  620. // 打开成功
  621. },
  622. fail(e) {
  623. console.log(e, '失败')
  624. }
  625. })
  626. } else if (id == 3) {
  627. uni.redirectTo({
  628. url: urls,
  629. fail: (err) => {
  630. uni.reLaunch({
  631. url: urls
  632. })
  633. }
  634. })
  635. }
  636. },
  637. //用户访问
  638. getUserVisits() {
  639. this.$api.my.userVisits({
  640. page: '/pages/index/index'
  641. }).then(res => {
  642. console.log(res.data);
  643. })
  644. },
  645. //跳转方法
  646. // jumpHAppID(id, urls) {
  647. // if (id == 1) {
  648. // const url = urls; // 跳转的外链
  649. // const navtitle = 'H5'; // 这个标题是你自己可以设置的
  650. // uni.navigateTo({
  651. // // 跳转到webview页面
  652. // url: `/pages/webview/webview?url=${url}&nav=${navtitle}`,
  653. // success: () => {
  654. // console.log('成功')
  655. // },
  656. // fail: (e) => {
  657. // console.log(e, "失败")
  658. // }
  659. // });
  660. // } else if (id == 2) {
  661. // let obj = JSON.parse(urls);
  662. // wx.navigateToMiniProgram({
  663. // appId: `${obj.appid}`, //appid
  664. // path: `${obj.path}`, //path
  665. // extraData: { //参数
  666. // foo: 'bar'
  667. // },
  668. // // envVersion: 'develop', //开发版develop 开发版 trial 体验版 release 正式版
  669. // success(res) {
  670. // console.log('成功')
  671. // // 打开成功
  672. // },
  673. // fail(e) {
  674. // console.log(e, '失败')
  675. // }
  676. // })
  677. // } else if (id == 3) {
  678. // uni.redirectTo({
  679. // url: urls,
  680. // fail:(err)=>{
  681. // uni.reLaunch({
  682. // url: urls
  683. // })
  684. // }
  685. // })
  686. // }
  687. // },
  688. //查看更多商品
  689. geMore() {
  690. if (this.admin == undefined) {
  691. uni.navigateTo({
  692. url: '/pages/login/login'
  693. })
  694. } else {
  695. uni.navigateTo({
  696. url: '/pages/goods/goods'
  697. })
  698. }
  699. },
  700. //跳转产品详情
  701. goToProduct(id) {
  702. if (this.admin == undefined) {
  703. uni.navigateTo({
  704. url: '/pages/login/login'
  705. })
  706. } else {
  707. uni.navigateTo({
  708. url: `/pages/goods/goods-detail/index?id=${id}&type=1`
  709. })
  710. }
  711. },
  712. //产品列表
  713. goProduceList() {
  714. uni.navigateTo({
  715. url: '/pages/goods/goods'
  716. })
  717. },
  718. //活动列表
  719. goSpecialList() {
  720. uni.navigateTo({
  721. url: '/pages/index/active-list/index'
  722. })
  723. },
  724. change2(e) {
  725. this.current2 = e.detail.current;
  726. },
  727. getCode() {
  728. return new Promise((resolve, reject) => {
  729. uni.getUserInfo({
  730. success: loginRes => {
  731. console.log(loginRes);
  732. this.data.encryptData = loginRes.encryptedData,
  733. this.data.iv = loginRes.iv
  734. resolve(this.data)
  735. }
  736. })
  737. })
  738. },
  739. //获取微信登录的code码
  740. getmsg() {
  741. uni.login({
  742. provider: uni.$u.platform,
  743. success: res => {
  744. console.log(res, '------->res');
  745. this.getCode().then((data) => {
  746. console.log(this.data, '------>data');
  747. const params = {
  748. code: res.code,
  749. iv: data.iv,
  750. encryptData: data.encryptData
  751. }
  752. console.log(params);
  753. this.$api.my.myLogin(params).then(res => {
  754. if (res.code == 0) {
  755. let {
  756. token
  757. } = res.data
  758. this.$store.dispatch('user/token', token)
  759. // 获取活动列表
  760. this.getList()
  761. //用户访问
  762. this.getUserVisits()
  763. } else {
  764. uni.showToast({
  765. icon: 'none',
  766. title: res.msg
  767. })
  768. }
  769. })
  770. })
  771. }
  772. })
  773. }
  774. },
  775. }
  776. </script>
  777. <style lang="scss" src="./index.scss" scoped></style>