index.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798
  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">
  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; " src="/static/icon/vip.png" mode=""></image>
  96. </view>
  97. </movable-view>
  98. </movable-area>
  99. <!-- 广告的附图 -->
  100. <view 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. //加入会员跳转
  190. adviseVip: '',
  191. jump_type_vip: '',
  192. jump_config_vip: {},
  193. //用户个人信息,判断是否登录
  194. admin: '',
  195. //获取token
  196. data: {},
  197. //录播图是展示视频1:图片2:视频
  198. resource_type: '',
  199. //广告弹框跳转
  200. jup_type: '',
  201. jump_config: '',
  202. //广告弹框图
  203. popupData: {},
  204. //弹窗的类型 1只弹一次首次 2就是每次都弹啊
  205. times_type: '',
  206. //弹窗的显示0不显示 1显示
  207. popupImgStatus: '',
  208. //视频封面图
  209. isOpenVideo: false,
  210. videoCoverImg: '',
  211. videoSrc: '',
  212. in_page: '',
  213. type: '',
  214. //隐藏广告图
  215. isShowAdver: false,
  216. //广告图
  217. advertis: '',
  218. advData: {},
  219. //广告附图展示图片
  220. advertisInsetImg: '',
  221. advInsetImg: {},
  222. //广告图展示图片:
  223. advertisImg: '',
  224. //广告图展示视频
  225. goodsList: [{
  226. cover_img: 'https://t9.9026.com/imgs/11.png',
  227. name: '2023新春福兔系列礼盒 倾心甄选 待你拥有'
  228. },
  229. {
  230. cover_img: 'https://t9.9026.com/imgs/22.png',
  231. name: '2023新春福兔系列礼盒 倾心甄选 待你拥有'
  232. },
  233. {
  234. cover_img: 'https://t9.9026.com/imgs/33.png',
  235. name: '2023新春福兔系列礼盒 倾心甄选 待你拥有'
  236. },
  237. {
  238. cover_img: 'https://t9.9026.com/imgs/44.png',
  239. name: '2023新春福兔系列礼盒 倾心甄选 待你拥有'
  240. },
  241. ],
  242. status: 'noMore',
  243. contentText: {
  244. contentdown: '查看更多',
  245. contentrefresh: '加载中',
  246. contentnomore: '—— 已经到底啦 ——'
  247. },
  248. infoList: [],
  249. //轮播图
  250. info: [],
  251. dotsStyles: {
  252. bottom: 24,
  253. backgroundColor: 'rgba(255, 255, 255, .3)',
  254. border: '1px rgba(255, 255, 255, .3) solid',
  255. color: '#fff',
  256. selectedBackgroundColor: 'rgba(255, 255, 255, 1)',
  257. selectedBorder: '1px rgba(255, 255, 255, 1) solid'
  258. },
  259. dotsStylesBand: {
  260. bottom: -24,
  261. backgroundColor: 'rgba(198, 198, 198, 1)',
  262. border: '1px rgba(0, 0, 0, .3) solid',
  263. color: '#fff',
  264. selectedBackgroundColor: 'rgba(151, 151, 151, 1)',
  265. selectedBorder: '1px rgba(0, 0, 0, .9) solid'
  266. },
  267. //指示点显示位置
  268. current1: 0,
  269. current2: 0,
  270. //指示点模式
  271. mode: 'dot',
  272. // 金刚图
  273. navList: [],
  274. //活动专区
  275. specialList: [],
  276. isDevelopment: false,
  277. }
  278. },
  279. onTabItemTap(e) {
  280. console.log(e)
  281. },
  282. // 下拉刷新
  283. onPullDownRefresh() {
  284. setTimeout(() => {
  285. uni.stopPullDownRefresh();
  286. this.$store.dispatch('user/allset', null)
  287. this.getAllSet()
  288. this.getList()
  289. }, 1000);
  290. },
  291. onReady: function(res) {
  292. this.videoContext = uni.createVideoContext('myVideo')
  293. },
  294. onShow() {
  295. //获取token
  296. this.getmsg()
  297. this.admin = this.$store.getters.userInfo
  298. },
  299. onLoad() {
  300. this.getGoodsList()
  301. this.getAllSet()
  302. // this.isDevelopment = process.env.NODE_ENV === 'development';
  303. this.isDevelopment = true;
  304. this.playVideo(this.current1)
  305. },
  306. // 监听判断视频的播放与暂停
  307. watch: {
  308. current1: {
  309. handler(newName, oldName) {
  310. console.log(newName, oldName);
  311. const id = `myVideo${oldName}`
  312. this.currentVideo = uni.createVideoContext(id, this)
  313. this.$nextTick(() => {
  314. if (oldName != newName) {
  315. this.stopVideo(oldName)
  316. } else {
  317. this.playVideo(newName)
  318. }
  319. })
  320. },
  321. immediate: true,
  322. deep: true
  323. }
  324. },
  325. methods: {
  326. // **************** Data ***************//
  327. // 切换轮播图指示点
  328. change1(e) {
  329. this.current1 = e.detail.current;
  330. this.playVideo(this.current1)
  331. },
  332. // 播放视频
  333. playVideo(index) {
  334. console.log(111);
  335. this.$nextTick(() => {
  336. const id = `myVideo${index}`
  337. this.currentVideo = uni.createVideoContext(id, this)
  338. this.currentVideo.play()
  339. })
  340. },
  341. // 停止播放视频
  342. stopVideo(index) {
  343. this.$nextTick(() => {
  344. const id = `myVideo${index}`
  345. this.currentVideo = uni.createVideoContext(id, this)
  346. this.currentVideo.stop()
  347. })
  348. },
  349. //获取配置数据
  350. getAllSet() {
  351. this.$api.document.allSet().then(res => {
  352. this.$store.dispatch('user/allset', res.data)
  353. this.infoList = this.$store.getters.allset.banners
  354. this.navList = this.$store.getters.allset.nav_icon
  355. this.info = this.$store.getters.allset.partner
  356. //广告图
  357. this.advertis = this.$store.getters.allset.advertises.filter(item => {
  358. return item.in_page == 1
  359. })
  360. this.advData = this.advertis[0];
  361. if (this.advertis[0].type == 1) {
  362. this.in_page = 1
  363. this.type = 1
  364. this.advertisImg = this.advertis[0].img
  365. } else if (this.advertis[0].type == 2) {
  366. this.in_page = 1
  367. this.type = 2
  368. this.videoCoverImg = this.advertis[0].video_cover
  369. this.videoSrc = this.advertis[0].video
  370. }
  371. //胶囊图
  372. this.advertisInset = this.$store.getters.allset.advertises.filter(item => {
  373. return item.in_page == 2
  374. })
  375. this.advInsetImg = this.advertisInset[0]
  376. this.advertisInsetImg = this.advertisInset[0].img
  377. //广告弹框图
  378. this.popupData = this.$store.getters.allset.popup_ads[0]
  379. //弹窗是否展示
  380. this.popupImgStatus = this.popupData?.status
  381. this.times_type = this.popupData?.times_type
  382. //广告弹框跳转h5和小程序和内部
  383. this.jump_type = this.popupData?.jump_type,
  384. this.jump_config = this.popupData?.jump_config
  385. this.open()
  386. //加入vip跳转
  387. this.adviseVip = this.$store.getters.allset.add_member
  388. this.jump_type_vip = this.adviseVip.value.index_jump_type
  389. if (this.jump_type_vip == 1) {
  390. this.jump_config_vip = this.adviseVip.value.index_h5_url
  391. } else if (this.jump_type_vip == 2) {
  392. this.jump_config_vip.appid = this.adviseVip.value.index_appid
  393. this.jump_config_vip.path = this.adviseVip.value.index_path
  394. } else if (this.jump_type_vip == 3) {
  395. this.jump_config_vip = this.adviseVip.value.index_other_path
  396. }
  397. })
  398. },
  399. // 获取活动列表
  400. getList() {
  401. this.$api.active.getActiveList({
  402. page: 0,
  403. keyword: '',
  404. category_id: ''
  405. }).then(res => {
  406. console.log(res, '活动列表')
  407. if (res.code == 0) {
  408. this.specialList = res.data.data
  409. }
  410. })
  411. },
  412. //产品列表type:1,第三方购买产品
  413. getGoodsList(category_id) {
  414. this.$api.product.getProducts({
  415. type: 1,
  416. page: 0,
  417. }).then(res => {
  418. this.goodsList = res.data.data.slice(0, 4)
  419. this.shortLong()
  420. console.log(this.goodsList, '------>产品图');
  421. })
  422. },
  423. //产品详情
  424. produceDetail(id) {
  425. uni.navigateTo({
  426. url: `/pages/goods/goods-detail/index?id=${id}&type=1`
  427. })
  428. },
  429. // **************** Dev ***************//
  430. shortLong() {
  431. this.goodsList.forEach((item, index, arr) => {
  432. if (index % 4 === 0) {
  433. item.short = true
  434. }
  435. if (index % 4 === 1) {
  436. item.long = true
  437. }
  438. if (index % 4 === 2) {
  439. item.long = true
  440. item.marginTop = -68 + "rpx"
  441. }
  442. if (index % 4 === 3) {
  443. item.short = true
  444. }
  445. })
  446. },
  447. //隐藏图片
  448. cleanCoverImg() {
  449. this.isShowAdver = !this.isShowAdver
  450. },
  451. //打开弹框
  452. open() {
  453. console.log(this.popupImgStatus, this.times_type);
  454. // 从本地缓存中同步获取指定 key 对应的内容,用于判断是否是第一次打开应用
  455. if (this.popupImgStatus == 1) {
  456. if (this.times_type == 1) {
  457. //首次进入弹窗
  458. const value = uni.getStorageSync('launchFlag');
  459. if (value) {
  460. console.log('首次弹窗')
  461. } else {
  462. // 没有值,跳到引导页,并存储,下次打开就不会进去引导页
  463. uni.setStorage({
  464. key: 'launchFlag',
  465. data: true
  466. });
  467. this.$refs.popup.open('center')
  468. }
  469. } else {
  470. this.$refs.popup.open('center') //每次都弹
  471. }
  472. } else {
  473. this.$refs.popup.close() //不显示广告弹框
  474. }
  475. },
  476. //关闭弹框
  477. closePopupBanner() {
  478. this.$refs.popup.close()
  479. },
  480. //点击视频封面图片,播放视频
  481. openVideoPlay() {
  482. this.isOpenVideo = !this.isOpenVideo
  483. this.videoContext.play()
  484. },
  485. // **************** 跳转 ***************//
  486. //合同伙伴跳转h5和小程序
  487. goGoodsDetail(id, urls) {
  488. console.log(urls, '----->url');
  489. if (id == 1) {
  490. const url = urls; // 跳转的外链
  491. const navtitle = 'H5'; // 这个标题是你自己可以设置的
  492. uni.navigateTo({
  493. // 跳转到webview页面
  494. url: `/pages/webview/webview?url=${url}&nav=${navtitle}`,
  495. success: () => {
  496. console.log('成功')
  497. },
  498. fail: (e) => {
  499. console.log(e, "失败")
  500. }
  501. });
  502. } else if (id == 2) {
  503. let obj = JSON.parse(urls);
  504. wx.navigateToMiniProgram({
  505. appId: `${obj.appid}`, //appid
  506. path: `${obj.path}`, //path
  507. extraData: { //参数
  508. foo: 'bar'
  509. },
  510. // envVersion: 'develop', //开发版develop 开发版 trial 体验版 release 正式版
  511. success(res) {
  512. console.log('成功')
  513. // 打开成功
  514. },
  515. fail(e) {
  516. console.log(e, '失败')
  517. }
  518. })
  519. }
  520. },
  521. // 活动详情页
  522. activeDetail(id) {
  523. uni.navigateTo({
  524. url: '/pages/index/active-detail/index?id=' + id
  525. })
  526. },
  527. // 点赞活动
  528. kudosActive(id, index) {
  529. let beforeLike = this.specialList[index].is_like
  530. this.$api.active.kudos({
  531. activity_id: id
  532. }).then(res => {
  533. console.log(res, '点赞')
  534. if (res.code == 0) {
  535. if (beforeLike == 1) {
  536. this.specialList[index].is_like = 0
  537. uni.showToast({
  538. icon: 'none',
  539. title: '取消点赞'
  540. })
  541. } else {
  542. this.specialList[index].is_like = 1
  543. uni.showToast({
  544. icon: 'none',
  545. title: '点赞成功'
  546. })
  547. }
  548. }
  549. })
  550. },
  551. //获取当前页面路径
  552. getPageUrl() {
  553. const pages = getCurrentPages();
  554. console.log(pages, '--------->pages')
  555. if (pages.length == 1) {
  556. const currentPage = pages[0];
  557. let pageUrl = `/${currentPage.route}`;
  558. return pageUrl
  559. console.log('当前页面url:', pageUrl);
  560. } else {
  561. const currentPage = pages[pages.length - 1];
  562. let pageUrl = `/${currentPage.route}`;
  563. return pageUrl
  564. console.log('当前页面url:', pageUrl);
  565. }
  566. },
  567. // 跳转其他小程序
  568. goJoin() {
  569. let _this = this
  570. this.jumpHAppID(this.jump_type_vip, this.jump_config_vip)
  571. },
  572. // 跳转其他小程序
  573. jumpHAppID(id, urls) {
  574. if (id == 1) {
  575. const url = urls; // 跳转的外链
  576. const navtitle = 'H5'; // 这个标题是你自己可以设置的
  577. uni.navigateTo({
  578. // 跳转到webview页面
  579. url: `/pages/webview/webview?url=${url}&nav=${navtitle}`,
  580. success: () => {
  581. console.log('成功')
  582. },
  583. fail: (e) => {
  584. console.log(e, "失败")
  585. }
  586. });
  587. } else if (id == 2) {
  588. let _this = this
  589. let obj = urls;
  590. console.log(obj, '----->obj');
  591. wx.navigateToMiniProgram({
  592. appId: `${obj.appid}`, //appid
  593. path: `${obj.path}`, //path
  594. extraData: { //参数
  595. foo: 'bar'
  596. },
  597. // envVersion: 'develop', //开发版develop 开发版 trial 体验版 release 正式版
  598. success(res) {
  599. let page = _this.getPageUrl()
  600. let user_id = ''
  601. if (_this.admin != null) {
  602. user_id = _this.admin.id
  603. } else {
  604. user_id = 0
  605. }
  606. _this.$api.my.userMemberAdd({
  607. user_id,
  608. page,
  609. }).then(res => {
  610. console.log(res.data);
  611. })
  612. // 打开成功
  613. },
  614. fail(e) {
  615. console.log(e, '失败')
  616. }
  617. })
  618. } else if (id == 3) {
  619. uni.redirectTo({
  620. url: urls,
  621. fail: (err) => {
  622. uni.reLaunch({
  623. url: urls
  624. })
  625. }
  626. })
  627. }
  628. },
  629. //用户访问
  630. getUserVisits() {
  631. this.$api.my.userVisits({
  632. page: '/pages/index/index'
  633. }).then(res => {
  634. console.log(res.data);
  635. })
  636. },
  637. //跳转方法
  638. // jumpHAppID(id, urls) {
  639. // if (id == 1) {
  640. // const url = urls; // 跳转的外链
  641. // const navtitle = 'H5'; // 这个标题是你自己可以设置的
  642. // uni.navigateTo({
  643. // // 跳转到webview页面
  644. // url: `/pages/webview/webview?url=${url}&nav=${navtitle}`,
  645. // success: () => {
  646. // console.log('成功')
  647. // },
  648. // fail: (e) => {
  649. // console.log(e, "失败")
  650. // }
  651. // });
  652. // } else if (id == 2) {
  653. // let obj = JSON.parse(urls);
  654. // wx.navigateToMiniProgram({
  655. // appId: `${obj.appid}`, //appid
  656. // path: `${obj.path}`, //path
  657. // extraData: { //参数
  658. // foo: 'bar'
  659. // },
  660. // // envVersion: 'develop', //开发版develop 开发版 trial 体验版 release 正式版
  661. // success(res) {
  662. // console.log('成功')
  663. // // 打开成功
  664. // },
  665. // fail(e) {
  666. // console.log(e, '失败')
  667. // }
  668. // })
  669. // } else if (id == 3) {
  670. // uni.redirectTo({
  671. // url: urls,
  672. // fail:(err)=>{
  673. // uni.reLaunch({
  674. // url: urls
  675. // })
  676. // }
  677. // })
  678. // }
  679. // },
  680. //查看更多商品
  681. geMore() {
  682. if (this.admin == undefined) {
  683. uni.navigateTo({
  684. url: '/pages/login/login'
  685. })
  686. } else {
  687. uni.navigateTo({
  688. url: '/pages/goods/goods'
  689. })
  690. }
  691. },
  692. //跳转产品详情
  693. goToProduct(id) {
  694. if (this.admin == undefined) {
  695. uni.navigateTo({
  696. url: '/pages/login/login'
  697. })
  698. } else {
  699. uni.navigateTo({
  700. url: `/pages/goods/goods-detail/index?id=${id}&type=1`
  701. })
  702. }
  703. },
  704. //产品列表
  705. goProduceList() {
  706. uni.navigateTo({
  707. url: '/pages/goods/goods'
  708. })
  709. },
  710. //活动列表
  711. goSpecialList() {
  712. uni.navigateTo({
  713. url: '/pages/index/active-list/index'
  714. })
  715. },
  716. change2(e) {
  717. this.current2 = e.detail.current;
  718. },
  719. getCode() {
  720. return new Promise((resolve, reject) => {
  721. uni.getUserInfo({
  722. success: loginRes => {
  723. console.log(loginRes);
  724. this.data.encryptData = loginRes.encryptedData,
  725. this.data.iv = loginRes.iv
  726. resolve(this.data)
  727. }
  728. })
  729. })
  730. },
  731. //获取微信登录的code码
  732. getmsg() {
  733. uni.login({
  734. provider: uni.$u.platform,
  735. success: res => {
  736. console.log(res, '------->res');
  737. this.getCode().then((data) => {
  738. console.log(this.data, '------>data');
  739. const params = {
  740. code: res.code,
  741. iv: data.iv,
  742. encryptData: data.encryptData
  743. }
  744. console.log(params);
  745. this.$api.my.myLogin(params).then(res => {
  746. if (res.code == 0) {
  747. let {
  748. token
  749. } = res.data
  750. this.$store.dispatch('user/token', token)
  751. // 获取活动列表
  752. this.getList()
  753. //用户访问
  754. this.getUserVisits()
  755. } else {
  756. uni.showToast({
  757. icon: 'none',
  758. title: res.msg
  759. })
  760. }
  761. })
  762. })
  763. }
  764. })
  765. }
  766. },
  767. }
  768. </script>
  769. <style lang="scss" src="./index.scss" scoped></style>