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" v-if="advertis.length != 0 ">
  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. if(this.advertis.length != 0 ){
  142. this.advData = this.advertis[0];
  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. //点击视频封面图片,播放视频
  158. openVideoPlay() {
  159. this.isOpenVideo = !this.isOpenVideo
  160. this.videoContext.play()
  161. },
  162. //跳转方法
  163. jumpHAppID(id, urls) {
  164. if (id == 1) {
  165. const url = urls; // 跳转的外链
  166. const navtitle = 'H5'; // 这个标题是你自己可以设置的
  167. uni.navigateTo({
  168. // 跳转到webview页面
  169. url: `/pages/webview/webview?url=${url}&nav=${navtitle}`,
  170. success: () => {
  171. console.log('成功')
  172. },
  173. fail: (e) => {
  174. console.log(e, "失败")
  175. }
  176. });
  177. } else if (id == 2) {
  178. let obj = JSON.parse(urls);
  179. wx.navigateToMiniProgram({
  180. appId: `${obj.appid}`, //appid
  181. path: `${obj.path}`, //path
  182. extraData: { //参数
  183. foo: 'bar'
  184. },
  185. // envVersion: 'develop', //开发版develop 开发版 trial 体验版 release 正式版
  186. success(res) {
  187. console.log('成功')
  188. // 打开成功
  189. },
  190. fail(e) {
  191. console.log(e, '失败')
  192. }
  193. })
  194. } else if (id == 3) {
  195. uni.redirectTo({
  196. url: urls,
  197. fail: (err) => {
  198. uni.reLaunch({
  199. url: urls
  200. })
  201. }
  202. })
  203. }
  204. },
  205. //点击图片跳转
  206. goOtherPage(id, url) {
  207. this.jumpHAppID(id, url)
  208. },
  209. // 返回首页
  210. goBack() {
  211. uni.reLaunch({
  212. url: '/pages/index/index'
  213. })
  214. },
  215. // 跳转订单详情
  216. goOrderDetail() {
  217. uni.navigateTo({
  218. url: '/pages/my/myorders/orders'
  219. })
  220. },
  221. //获取当前页面路径
  222. getPageUrl() {
  223. const pages = getCurrentPages();
  224. console.log(pages, '--------->pages')
  225. if (pages.length == 1) {
  226. const currentPage = pages[0];
  227. let pageUrl = `/${currentPage.route}`;
  228. return pageUrl
  229. console.log('当前页面url:', pageUrl);
  230. } else {
  231. const currentPage = pages[pages.length - 1];
  232. let pageUrl = `/${currentPage.route}`;
  233. return pageUrl
  234. console.log('当前页面url:', pageUrl);
  235. }
  236. },
  237. // 跳转其他小程序
  238. jumpHAppIDVip(id, urls) {
  239. if (id == 1) {
  240. const url = urls; // 跳转的外链
  241. const navtitle = 'H5'; // 这个标题是你自己可以设置的
  242. uni.navigateTo({
  243. // 跳转到webview页面
  244. url: `/pages/webview/webview?url=${url}&nav=${navtitle}`,
  245. success: () => {
  246. console.log('成功')
  247. },
  248. fail: (e) => {
  249. console.log(e, "失败")
  250. }
  251. });
  252. } else if (id == 2) {
  253. let _this = this
  254. let obj = urls;
  255. console.log(obj, '----->obj');
  256. wx.navigateToMiniProgram({
  257. appId: `${obj.appid}`, //appid
  258. path: `${obj.path}`, //path
  259. extraData: { //参数
  260. foo: 'bar'
  261. },
  262. // envVersion: 'develop', //开发版develop 开发版 trial 体验版 release 正式版
  263. success(res) {
  264. let page = _this.getPageUrl()
  265. let user_id = ''
  266. if (_this.admin != null) {
  267. user_id = _this.admin.id
  268. } else {
  269. user_id = 0
  270. }
  271. _this.$api.my.userMemberAdd({
  272. user_id,
  273. page,
  274. }).then(res => {
  275. console.log(res.data);
  276. })
  277. // 打开成功
  278. },
  279. fail(e) {
  280. console.log(e, '失败')
  281. }
  282. })
  283. } else if (id == 3) {
  284. uni.redirectTo({
  285. url: urls,
  286. fail: (err) => {
  287. uni.reLaunch({
  288. url: urls
  289. })
  290. }
  291. })
  292. }
  293. },
  294. // 跳转其他小程序
  295. goJoin() {
  296. let _this = this
  297. this.jumpHAppIDVip(this.jump_type_vip, this.jump_config_vip)
  298. },
  299. }
  300. }
  301. </script>
  302. <style lang="scss" scoped>
  303. $pageColor:#F9F9F9;
  304. $bgColor:#FFFFFF;
  305. @mixin flexlayout {
  306. display: flex;
  307. align-items: center;
  308. justify-content: center;
  309. }
  310. .exchangeDetail {
  311. height: 100%;
  312. background: $pageColor;
  313. }
  314. .detailCard {
  315. width: 750rpx;
  316. height: 446rpx;
  317. display: flex;
  318. flex-direction: column;
  319. justify-content: center;
  320. align-items: center;
  321. image {
  322. width: 120rpx;
  323. height: 120rpx;
  324. margin-bottom: 48rpx;
  325. }
  326. text {
  327. display: block;
  328. font-size: 32rpx;
  329. font-family: PingFangSC-Medium, PingFang SC;
  330. font-weight: 500;
  331. color: #080F18;
  332. }
  333. }
  334. .btn {
  335. width: 750rpx;
  336. height: 76rpx;
  337. display: flex;
  338. justify-content: space-between;
  339. align-items: center;
  340. padding: 0 32rpx;
  341. .back {
  342. width: 332rpx;
  343. height: 76rpx;
  344. background: #F5F5F5;
  345. border-radius: 8rpx;
  346. @include flexlayout() text {
  347. font-size: 30rpx;
  348. font-family: PingFang-SC-Bold, PingFang-SC;
  349. font-weight: bold;
  350. color: #FF6301;
  351. }
  352. }
  353. .checkout {
  354. width: 332rpx;
  355. height: 76rpx;
  356. background: linear-gradient(270deg, #FF6200 0%, #FF9342 100%);
  357. border-radius: 8rpx;
  358. @include flexlayout() text {
  359. font-size: 30rpx;
  360. font-family: PingFang-SC-Bold, PingFang-SC;
  361. font-weight: bold;
  362. color: #FFFFFF;
  363. }
  364. }
  365. }
  366. .bottomCard {
  367. width: 690rpx;
  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>