gift.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <app-layout>
  3. <scroll-view scroll-y :style="{'height':`${windowHeight}px`}">
  4. <view class="app-goods" v-show="loading">
  5. <view class="banner">
  6. <app-banner
  7. :videoUrl="goods.video_url"
  8. :picList="goods.pic_list"
  9. :goods_id="goods.id"
  10. :isCart="false"
  11. sign="exchange"
  12. ></app-banner>
  13. </view>
  14. <view class="other-info">
  15. <view class="t-omit-two goods-name">{{goods.name}}</view>
  16. <view class="code" :style="{'color': status == 'unused' ? getTheme.color : '#999999','background-color': status == 'unused' ? getTheme.background_o : '#f5f5f5'}">{{code}}</view>
  17. <view v-if="status == 'unused'" class="app-share">
  18. <app-form-id @click="shareShow = true">
  19. <image class="app-icon" src="../../../static/image/icon/icon-share.png"></image>
  20. <text class="app-text">赠送</text>
  21. </app-form-id>
  22. </view>
  23. </view>
  24. <app-share-qr-code v-model="shareShow"
  25. :url="url"
  26. title="生成赠送海报"
  27. :goods="goods"
  28. @share="hShareAppMessage"
  29. :theme="getTheme"
  30. :has-poster-nav="false"
  31. ></app-share-qr-code>
  32. <!-- 商品详情 -->
  33. <bd-detail :detail="goods.detail"></bd-detail>
  34. <!-- 底部空格 -->
  35. <view class="safe-area-inset-bottom">
  36. <view class="u-bottom-height"></view>
  37. </view>
  38. <!-- 底部按钮 -->
  39. <view class="safe-area-inset-bottom u-bottom-fixed">
  40. <view class="buttons dir-left-nowrap">
  41. <view class="app-button main-center cross-center">
  42. <view @click="copy" v-if="status == 'unused'" class="app-exhange" :style="{'background': getTheme.background_s_gradient_o,'color': getTheme.secondary_text}">
  43. 复制兑换码
  44. </view>
  45. <view @click="toExchange" v-if="status == 'unused'" class="app-exhange" :style="{'background': getTheme.background_gradient_o,'color': getTheme.main_text}">
  46. 立即兑换
  47. </view>
  48. <view class="app-over" v-if="status != 'unused'">
  49. {{status == 'used' ? '已兑换': '已失效'}}
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </scroll-view>
  56. </app-layout>
  57. </template>
  58. <script>
  59. import {mapGetters, mapState} from 'vuex';
  60. import appBanner from '../../../components/page-component/goods/app-goods-banner.vue';
  61. import appShareQrCode from '../../../components/page-component/app-share-qr-code-poster/app-share-qr-code-poster.vue';
  62. import bdDetail from '@/components/page-component/goods/bd-detail.vue';
  63. export default {
  64. name: 'goods',
  65. data() {
  66. return {
  67. shareShow: false,
  68. goods: {},
  69. url: this.$api.exchange.qrcode,
  70. show: false,
  71. list: [],
  72. code: null,
  73. id: null,
  74. status: '',
  75. windowHeight: 667,
  76. loading: false,
  77. first: true,
  78. }
  79. },
  80. onLoad(options) { this.$commonLoad.onload(options);
  81. let that = this;
  82. that.code = options.code;
  83. that.windowHeight = uni.getSystemInfoSync().windowHeight;
  84. that.$showLoading({
  85. type: 'global',
  86. text: '加载中...'
  87. });
  88. that.request({
  89. url: that.$api.exchange.me_detail,
  90. data: {
  91. code: that.code,
  92. }
  93. }).then(response => {
  94. if(response) {
  95. that.first = false;
  96. let { goods_attr, code,status } = response;
  97. that.url = that.url + '&code=' + code;
  98. that.goods = goods_attr;
  99. that.code = code;
  100. that.status = status;
  101. that.loading = true;
  102. that.$hideLoading();
  103. }
  104. });
  105. },
  106. onShow() {
  107. if(this.first) {
  108. return false
  109. }
  110. this.$showLoading();
  111. this.$nextTick(() => {
  112. let that = this;
  113. that.request({
  114. url: that.$api.exchange.me_detail,
  115. data: {
  116. code: that.code,
  117. }
  118. }).then(response => {
  119. let { goods_attr, code,status } = response;
  120. that.goods = goods_attr;
  121. that.code = code;
  122. that.status = status;
  123. that.loading = true;
  124. that.$hideLoading();
  125. });
  126. })
  127. },
  128. computed: {
  129. ...mapState('gConfig',{
  130. iphone: (data) => {
  131. return data.iphone;
  132. },
  133. iphoneHeight: (state) =>{
  134. return state.iphoneHeight;
  135. },
  136. }),
  137. ...mapGetters('mallConfig', {
  138. getTheme: 'getTheme',
  139. }),
  140. ...mapState({
  141. mall: state => state.mallConfig.mall,
  142. userInfo: state => state.user.info
  143. })
  144. },
  145. // #ifdef MP
  146. onShareAppMessage() {
  147. return this.hShareAppMessage();
  148. },
  149. // #endif
  150. methods: {
  151. hShareAppMessage(s = false) {
  152. return this.$shareAppMessage({
  153. path: '/plugins/exchange/gift/gift',
  154. title: this.goods.app_share_title ? this.goods.app_share_title : this.goods.name,
  155. imageUrl: this.goods.app_share_pic ? this.goods.app_share_pic : '',
  156. params: {
  157. code: this.code,
  158. }
  159. }, s);
  160. },
  161. copy() {
  162. this.$utils.uniCopy({
  163. data: this.code,
  164. success() {
  165. //#ifndef MP-WEIXIN
  166. uni.showToast({title: '复制成功'});
  167. // #endif
  168. },
  169. });
  170. },
  171. toExchange() {
  172. uni.navigateTo({
  173. url: '/plugins/exchange/detail/detail?code=' + this.code
  174. })
  175. },
  176. async request({url, data}) {
  177. const response = await this.$request({
  178. url: url,
  179. data: data,
  180. });
  181. if (response.code === 0) {
  182. return response.data;
  183. }else {
  184. uni.showModal({
  185. title: '提示',
  186. content: response.msg,
  187. showCancel: false,
  188. success: function (res) {
  189. uni.navigateBack();
  190. }
  191. });
  192. }
  193. }
  194. },
  195. components: {
  196. 'app-banner': appBanner,
  197. 'app-share-qr-code': appShareQrCode,
  198. bdDetail
  199. }
  200. }
  201. </script>
  202. <style scoped lang="scss">
  203. .other-info {
  204. background-color: #fff;
  205. padding-top: 24rpx;
  206. padding-bottom: 24rpx;
  207. margin-bottom: 24rpx;
  208. position: relative;
  209. .goods-name {
  210. font-size: #{32rpx};
  211. color: #353535;
  212. margin: 0 #{24rpx} #{50rpx};
  213. }
  214. .code {
  215. margin-left: 24rpx;
  216. display: inline-block;
  217. padding: 16rpx 46rpx;
  218. border-radius: 40rpx;
  219. font-size: 32rpx;
  220. font-weight: 600;
  221. &.default {
  222. background-color: #F5F5F5;
  223. color: #999999;
  224. }
  225. }
  226. .app-share {
  227. width: #{40rpx};
  228. height: #{102rpx};
  229. position: absolute;
  230. right: #{24rpx};
  231. bottom: #{26rpx};
  232. .app-icon {
  233. width: #{40rpx};
  234. height: #{40rpx};
  235. }
  236. .app-text {
  237. color: #666666;
  238. font-size: #{20rpx};
  239. position: absolute;
  240. top: #{50rpx};
  241. left: 0;
  242. }
  243. }
  244. }
  245. .app-goods {
  246. background-color: #f7f7f7;
  247. }
  248. .buttons {
  249. width: #{750rpx};
  250. height: #{110rpx};
  251. border-top: #{1rpx} solid #e2e2e2;
  252. .app-button {
  253. width: 100%;
  254. height: #{110rpx};
  255. text-align: center;
  256. line-height: #{110rpx};
  257. background-color: #fff;
  258. .app-over {
  259. background: #e9e9e9;
  260. width: #{702rpx};
  261. border-radius: #{41rpx};
  262. color: #999999;
  263. height: #{82rpx};
  264. line-height: #{82rpx};
  265. font-size: #{28rpx};
  266. }
  267. .app-exhange {
  268. margin: 0 10rpx;
  269. width: 340rpx;
  270. border-radius: 41rpx;
  271. height: 82rpx;
  272. line-height: 82rpx;
  273. font-size: 28rpx;
  274. }
  275. }
  276. }
  277. .u-bottom-fixed {
  278. position: fixed;
  279. bottom: 0;
  280. left: 0;
  281. width: 100%;
  282. z-index: 1602;
  283. background-color: #ffffff;
  284. }
  285. .u-bottom-height {
  286. height: 110upx;
  287. }
  288. </style>