exchangeDetail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. <template>
  2. <view class="exchangeDetail">
  3. <!-- 自定义导航栏 -->
  4. <u-navbar :leftText='title' fixed safeAreaInsetTop :placeholder='true' :bgColor="bgColor" @leftClick='back'>
  5. </u-navbar>
  6. <!-- 兑换状态 -->
  7. <view class="detailCard" v-if="productType == 2 ">
  8. <image src="/static/icon/success.png"></image>
  9. <text>奖品兑换成功</text>
  10. </view>
  11. <view class="detailCard" v-if="productType == 1 ">
  12. <image src="/static/icon/success.png"></image>
  13. <text>商品兑换成功</text>
  14. <text>-{{integral}}积分</text>
  15. </view>
  16. <!-- 按钮 -->
  17. <view class="btn">
  18. <view class="back" @click="goBack">
  19. <text>返回首页</text>
  20. </view>
  21. <view class="checkout" @click="goOrderDetail">
  22. <text>查看订单</text>
  23. </view>
  24. </view>
  25. <!-- 加入会员 -->
  26. <view class="bottomCard">
  27. <!-- 广告图 -->
  28. <view class="home-banner">
  29. <view class="home-banner-img" v-if="in_page==3 && type == 1"
  30. @click="goOtherPage(jump_type,jump_config)">
  31. <image style="width: 100%; height: 492rpx;border-radius: 12rpx 12rpx 0 0;" :src="advData.img" mode="">
  32. </image>
  33. </view>
  34. <view class="home-banner-img" v-if="in_page==3 && type == 2">
  35. <image class="banner-img" v-if="!isOpenVideo" @click="openVideoPlay"
  36. style="width: 100%; height: 492rpx; border-radius: 12rpx 12rpx 0 0;" :src="videoCoverImg" mode=""></image>
  37. <video class="baner-video" id="myVideo" ref="myVideo"
  38. style="width: 100%; height: 492rpx;border-radius: 12rpx 12rpx 0 0;" :src="videoSrc" controls
  39. :enable-progress-gesture="false">
  40. </video>
  41. </view>
  42. </view>
  43. <view class="content" @click="goJoin">
  44. <text>立即加入IHG会员</text>
  45. <image src="/static/icon/right.png"></image>
  46. </view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. export default {
  52. data() {
  53. return {
  54. //跳转h5,小程序,其他页面
  55. jump_type_vip: '',
  56. jump_config_vip: {},
  57. //加入会员广告配置
  58. advise: '',
  59. //自定义导航栏
  60. bgColor: '#f9f9f9',
  61. title: '兑换详情',
  62. //积分商品1奖品2兑换
  63. productType: '',
  64. //积分
  65. integral: '',
  66. admin: '',
  67. isOpenVideo: false,
  68. jump_type: '',
  69. jump_config: '',
  70. advData: '',
  71. advertis: '',
  72. in_page: '',
  73. type: '',
  74. videoCoverImg: '',
  75. videoSrc: ''
  76. }
  77. },
  78. onReady: function(res) {
  79. this.videoContext = uni.createVideoContext('myVideo')
  80. },
  81. onLoad(o) {
  82. this.getAdvertis()
  83. this.admin = this.$store.getters.userInfo
  84. if (o.productType == 1) {
  85. this.productType = o.productType
  86. this.integral = o.integral
  87. }else if(o.productType == 2){
  88. this.productType = o.productType
  89. }
  90. this.advise = this.$store.getters.allset.add_member
  91. this.jump_type_vip = this.advise.value.exchange_jump_type
  92. if (this.jump_type_vip == 1) {
  93. this.jump_config_vip = this.advise.value.exchange_h5_url
  94. } else if (this.jump_type_vip == 2) {
  95. this.jump_config_vip.appid = this.advise.value.exchange_appid
  96. this.jump_config_vip.path = this.advise.value.exchange_path
  97. } else if (this.jump_type_vip == 3) {
  98. this.jump_config_vip = this.advise.value.exchange_other_path
  99. }
  100. },
  101. onUnload(){
  102. if(this.productType == 1){
  103. uni.$emit('refreshData')
  104. uni.redirectTo({
  105. url: "/pages/my/integral/integral"
  106. })
  107. }else if(this.productType == 2){
  108. uni.$emit('refreshPrizeData')
  109. uni.navigateBack({
  110. delta: 1,
  111. })
  112. }
  113. },
  114. methods: {
  115. //返回上一级
  116. back() {
  117. uni.navigateBack({
  118. delta: 1,
  119. })
  120. // if(this.productType == 1){
  121. // uni.$emit('refreshData')
  122. // uni.navigateBack({
  123. // delta: 1,
  124. // })
  125. // uni.redirectTo({
  126. // url: "/pages/my/integral/integral"
  127. // })
  128. // }else if(this.productType == 2){
  129. // uni.$emit('refreshPrizeData')
  130. // uni.navigateBack({
  131. // delta: 1,
  132. // })
  133. // }
  134. },
  135. //广告图
  136. getAdvertis() {
  137. this.$api.document.allSet().then(res => {
  138. this.advertis = res.data.advertises.filter(item => {
  139. return item.in_page == 3
  140. })
  141. this.advData = this.advertis[0];
  142. console.log(this.advData.img, '------>this.advData');
  143. if (this.advertis[0].type == 1) {
  144. this.in_page = 3
  145. this.type = 1
  146. this.jump_type = this.advData.jump_type
  147. this.jump_config = this.advData.jump_config
  148. } else if (this.advertis[0].type == 2) {
  149. this.in_page = 3
  150. this.type = 2
  151. this.videoCoverImg = this.advertis[0].video_cover
  152. this.videoSrc = this.advertis[0].video
  153. }
  154. })
  155. },
  156. //点击视频封面图片,播放视频
  157. openVideoPlay() {
  158. this.isOpenVideo = !this.isOpenVideo
  159. this.videoContext.play()
  160. },
  161. //跳转方法
  162. jumpHAppID(id, urls) {
  163. if (id == 1) {
  164. const url = urls; // 跳转的外链
  165. const navtitle = 'H5'; // 这个标题是你自己可以设置的
  166. uni.navigateTo({
  167. // 跳转到webview页面
  168. url: `/pages/webview/webview?url=${url}&nav=${navtitle}`,
  169. success: () => {
  170. console.log('成功')
  171. },
  172. fail: (e) => {
  173. console.log(e, "失败")
  174. }
  175. });
  176. } else if (id == 2) {
  177. let obj = JSON.parse(urls);
  178. wx.navigateToMiniProgram({
  179. appId: `${obj.appid}`, //appid
  180. path: `${obj.path}`, //path
  181. extraData: { //参数
  182. foo: 'bar'
  183. },
  184. // envVersion: 'develop', //开发版develop 开发版 trial 体验版 release 正式版
  185. success(res) {
  186. console.log('成功')
  187. // 打开成功
  188. },
  189. fail(e) {
  190. console.log(e, '失败')
  191. }
  192. })
  193. } else if (id == 3) {
  194. uni.redirectTo({
  195. url: urls,
  196. fail: (err) => {
  197. uni.reLaunch({
  198. url: urls
  199. })
  200. }
  201. })
  202. }
  203. },
  204. //点击图片跳转
  205. goOtherPage(id, url) {
  206. this.jumpHAppID(id, url)
  207. },
  208. // 返回首页
  209. goBack() {
  210. uni.reLaunch({
  211. url: '/pages/index/index'
  212. })
  213. },
  214. // 跳转订单详情
  215. goOrderDetail() {
  216. uni.navigateTo({
  217. url: '/pages/my/myorders/orders'
  218. })
  219. },
  220. //获取当前页面路径
  221. getPageUrl() {
  222. const pages = getCurrentPages();
  223. console.log(pages, '--------->pages')
  224. if (pages.length == 1) {
  225. const currentPage = pages[0];
  226. let pageUrl = `/${currentPage.route}`;
  227. return pageUrl
  228. console.log('当前页面url:', pageUrl);
  229. } else {
  230. const currentPage = pages[pages.length - 1];
  231. let pageUrl = `/${currentPage.route}`;
  232. return pageUrl
  233. console.log('当前页面url:', pageUrl);
  234. }
  235. },
  236. // 跳转其他小程序
  237. jumpHAppIDVip(id, urls) {
  238. if (id == 1) {
  239. const url = urls; // 跳转的外链
  240. const navtitle = 'H5'; // 这个标题是你自己可以设置的
  241. uni.navigateTo({
  242. // 跳转到webview页面
  243. url: `/pages/webview/webview?url=${url}&nav=${navtitle}`,
  244. success: () => {
  245. console.log('成功')
  246. },
  247. fail: (e) => {
  248. console.log(e, "失败")
  249. }
  250. });
  251. } else if (id == 2) {
  252. let _this = this
  253. let obj = urls;
  254. console.log(obj, '----->obj');
  255. wx.navigateToMiniProgram({
  256. appId: `${obj.appid}`, //appid
  257. path: `${obj.path}`, //path
  258. extraData: { //参数
  259. foo: 'bar'
  260. },
  261. // envVersion: 'develop', //开发版develop 开发版 trial 体验版 release 正式版
  262. success(res) {
  263. let page = _this.getPageUrl()
  264. let user_id = ''
  265. if (_this.admin != null) {
  266. user_id = _this.admin.id
  267. } else {
  268. user_id = 0
  269. }
  270. _this.$api.my.userMemberAdd({
  271. user_id,
  272. page,
  273. }).then(res => {
  274. console.log(res.data);
  275. })
  276. // 打开成功
  277. },
  278. fail(e) {
  279. console.log(e, '失败')
  280. }
  281. })
  282. } else if (id == 3) {
  283. uni.redirectTo({
  284. url: urls,
  285. fail: (err) => {
  286. uni.reLaunch({
  287. url: urls
  288. })
  289. }
  290. })
  291. }
  292. },
  293. // 跳转其他小程序
  294. goJoin() {
  295. let _this = this
  296. this.jumpHAppIDVip(this.jump_type_vip, this.jump_config_vip)
  297. },
  298. }
  299. }
  300. </script>
  301. <style lang="scss" scoped>
  302. $pageColor:#F9F9F9;
  303. $bgColor:#FFFFFF;
  304. @mixin flexlayout {
  305. display: flex;
  306. align-items: center;
  307. justify-content: center;
  308. }
  309. .exchangeDetail {
  310. height: 100%;
  311. background: $pageColor;
  312. }
  313. .detailCard {
  314. width: 750rpx;
  315. height: 446rpx;
  316. display: flex;
  317. flex-direction: column;
  318. justify-content: center;
  319. align-items: center;
  320. image {
  321. width: 120rpx;
  322. height: 120rpx;
  323. margin-bottom: 48rpx;
  324. }
  325. text {
  326. display: block;
  327. font-size: 32rpx;
  328. font-family: PingFangSC-Medium, PingFang SC;
  329. font-weight: 500;
  330. color: #080F18;
  331. }
  332. }
  333. .btn {
  334. width: 750rpx;
  335. height: 76rpx;
  336. display: flex;
  337. justify-content: space-between;
  338. align-items: center;
  339. padding: 0 32rpx;
  340. .back {
  341. width: 332rpx;
  342. height: 76rpx;
  343. background: #F5F5F5;
  344. border-radius: 8rpx;
  345. @include flexlayout() text {
  346. font-size: 30rpx;
  347. font-family: PingFang-SC-Bold, PingFang-SC;
  348. font-weight: bold;
  349. color: #FF6301;
  350. }
  351. }
  352. .checkout {
  353. width: 332rpx;
  354. height: 76rpx;
  355. background: linear-gradient(270deg, #FF6200 0%, #FF9342 100%);
  356. border-radius: 8rpx;
  357. @include flexlayout() text {
  358. font-size: 30rpx;
  359. font-family: PingFang-SC-Bold, PingFang-SC;
  360. font-weight: bold;
  361. color: #FFFFFF;
  362. }
  363. }
  364. }
  365. .bottomCard {
  366. width: 690rpx;
  367. height: 584rpx;
  368. background: #FFFFFF;
  369. box-shadow: 0px 8rpx 16rpx 0px rgba(220, 222, 229, 0.71);
  370. border-radius: 20rpx;
  371. background: $bgColor;
  372. margin-left: 30rpx;
  373. margin-top: 64rpx;
  374. position: relative;
  375. image {
  376. width: 690rpx;
  377. height: 492rpx;
  378. }
  379. .content {
  380. width: 690rpx;
  381. height: 92rpx;
  382. position: absolute;
  383. bottom: 0;
  384. margin-top: -9rpx;;
  385. @include flexlayout();
  386. image {
  387. width: 12rpx;
  388. height: 20rpx;
  389. margin-left: 8rpx;
  390. }
  391. text {
  392. font-size: 30rpx;
  393. font-family: PingFang-SC-Medium, PingFang-SC;
  394. font-weight: 500;
  395. color: #333333;
  396. text-shadow: 0px 8rpx 16rpx rgba(220, 222, 229, 0.71);
  397. }
  398. }
  399. }
  400. .home-banner {
  401. // height: 640rpx;
  402. // padding: 0 30rpx;
  403. // padding-top: 64rpx;
  404. .home-banner-img {
  405. position: relative;
  406. width: 100%;
  407. // height: 100%;
  408. .baner-video {
  409. position: absolute;
  410. top: 0;
  411. left: 0;
  412. }
  413. .banner-img {
  414. position: absolute;
  415. top: 0;
  416. left: 0;
  417. z-index: 9;
  418. }
  419. .img-clean {
  420. position: absolute;
  421. right: 28rpx;
  422. top: 30rpx;
  423. z-index: 99;
  424. }
  425. .img-IHg {
  426. width: 84rpx;
  427. height: 84rpx;
  428. background-color: #fff;
  429. box-shadow: 0px 8rpx 24rpx 0px rgba(220, 222, 229, 0.4);
  430. border-radius: 50%;
  431. display: flex;
  432. align-items: center;
  433. justify-content: center;
  434. position: fixed;
  435. top: 1030rpx;
  436. right: 30rpx;
  437. z-index: 99;
  438. }
  439. }
  440. }
  441. </style>