app-card-give.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <view class="give" v-if="card">
  3. <view class="content" :style="contentStyle">
  4. <view class="avatar dir-left-nowrap main-center cross-center">
  5. <image :src="card.avatar"></image>
  6. </view>
  7. <view class="nickname">{{card.nickname}}</view>
  8. <view class="title">送你一张碎屏险</view>
  9. <template v-if="card.status == 2">
  10. <view class="pic dir-left-nowrap main-between cross-center">
  11. <view class="card-title box-grow-0">
  12. <image :src="card.pic_url"></image>
  13. </view>
  14. <view class="name t-omit-two box-grow-0">{{card.name}}</view>
  15. <view class="box-grow-1"></view>
  16. </view>
  17. <view class="reset-time">剩余次数:{{card.reset_number}}次</view>
  18. <view class="time">有效期:{{card.start_time}} - {{card.end_time}}</view>
  19. <view class="card-btn-group dir-left-nowrap main-center">
  20. <view class="card-btn btn-0 box-grow-0" @click="back">
  21. <app-image :img-src="card.img_back" width="100%" height="100%"></app-image>
  22. </view>
  23. <view class="card-btn btn-0 box-grow-0" @click="shareShow = true">
  24. <app-image :img-src="card.img_share" width="100%" height="100%"></app-image>
  25. </view>
  26. </view>
  27. <view>
  28. <app-share-qr-code v-model="shareShow" title="生成碎屏险海报"
  29. :poster-url="`/pages/poster/poster?card_id=` + card.id"
  30. :has-poster-nav="true"
  31. ></app-share-qr-code>
  32. </view>
  33. </template>
  34. <view class="card-btn btn-1" v-else @click="receive">
  35. <app-image :img-src="card.img_receive" width="100%" height="100%"></app-image>
  36. </view>
  37. <view class="card-modal dir-top-nowrap cross-center main-center" v-if="modal.show">
  38. <view class="modal-content" :style="{backgroundImage: `url(`+card.img_finish_receiving+`)`}">
  39. <view class="error">{{modal.msg}}</view>
  40. <view class="modal-btn" @click="modal.show = false"></view>
  41. </view>
  42. </view>
  43. </view>
  44. <view>
  45. <app-related-suggestion-product v-if="recommendGoodsList && recommendGoodsList.length"
  46. :list="recommendGoodsList"
  47. text="您或许会喜欢"
  48. :theme="getTheme"
  49. ></app-related-suggestion-product>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import {mapGetters, mapState} from 'vuex';
  55. import AppRelatedSuggestionProduct
  56. from '../../../components/page-component/app-related-suggestion-product/app-related-suggestion-product';
  57. import appShareQrCode
  58. from '../../../components/page-component/app-share-qr-code-poster/app-share-qr-code-poster.vue';
  59. import jump from '../../../core/jump.js';
  60. export default {
  61. name: "app-card-give",
  62. components: {
  63. AppRelatedSuggestionProduct, appShareQrCode
  64. },
  65. props: {
  66. card: {
  67. type: Object | null,
  68. default() {
  69. return null;
  70. }
  71. }
  72. },
  73. data() {
  74. return {
  75. recommendGoodsList: null,
  76. shareShow: false,
  77. modal: {
  78. show: false,
  79. msg: ''
  80. },
  81. };
  82. },
  83. computed: {
  84. ...mapState({
  85. appImg: state => state.mallConfig.__wxapp_img,
  86. }),
  87. ...mapGetters('mallConfig', {
  88. getTheme: 'getTheme',
  89. }),
  90. contentStyle() {
  91. let style = '';
  92. if (this.card.status === 2) {
  93. style = `background-image: url('${this.card.receive_card_bg}')`;
  94. } else {
  95. style = `background-image: url('${this.card.card_bg}')`;
  96. }
  97. return style;
  98. }
  99. },
  100. created() {
  101. this.loadRecommendGoodsList();
  102. },
  103. methods: {
  104. loadRecommendGoodsList() {
  105. this.$request({
  106. url: this.$api.goods.new_recommend,
  107. method: 'get',
  108. data: {
  109. type: 'order_pay',
  110. },
  111. }).then(response => {
  112. if (response.code === 0) {
  113. this.recommendGoodsList = response.data.list;
  114. }
  115. }).catch(e => {
  116. });
  117. },
  118. back() {
  119. jump({
  120. open_type: 'redirect',
  121. url: '/pages/index/index'
  122. })
  123. },
  124. receive() {
  125. this.$showLoading();
  126. this.$request({
  127. url: this.$api.card.receivesp,
  128. method: 'get',
  129. data: {
  130. cardId: this.card.id
  131. }
  132. }).then(response => {
  133. this.$hideLoading();
  134. if (response.code === 0) {
  135. this.$emit('receive')
  136. } else {
  137. this.modal = {
  138. show: true,
  139. msg: response.msg
  140. }
  141. }
  142. })
  143. }
  144. }
  145. }
  146. </script>
  147. <style scoped lang="scss">
  148. .give {
  149. background-color: #ffffff;
  150. }
  151. .content {
  152. width: #{750rpx};
  153. height: #{880rpx};
  154. background-size: contain;
  155. background-repeat: no-repeat;
  156. background-position: center;
  157. padding-top: #{46rpx};
  158. text-align: center;
  159. background-color: #ffffff;
  160. line-height: 1;
  161. .avatar {
  162. width: #{130rpx};
  163. height: #{130rpx};
  164. margin: #{0 auto 30rpx auto};
  165. border-radius: #{130rpx};
  166. overflow: hidden;
  167. image {
  168. width: 100%;
  169. height: 100%;
  170. display: block;
  171. }
  172. }
  173. .nickname {
  174. font-size: $uni-font-size-general-one;
  175. }
  176. .title {
  177. margin-top: #{40rpx};
  178. font-size: $uni-font-size-import-two;
  179. }
  180. .pic {
  181. margin: #{76rpx auto 0 auto};
  182. width: #{636rpx};
  183. height: #{200rpx};
  184. .card-title {
  185. margin-left: #{40rpx};
  186. border-radius: #{120rpx};
  187. overflow: hidden;
  188. }
  189. image {
  190. width: #{120rpx};
  191. height: #{120rpx};
  192. display: block;
  193. }
  194. .name {
  195. margin-left: #{21rpx};
  196. width: #{300rpx};
  197. }
  198. }
  199. .reset-time {
  200. height: #{52rpx};
  201. font-size: $uni-font-size-weak-two;
  202. line-height: #{50rpx};
  203. margin: #{40rpx auto 0 auto};
  204. }
  205. .time {
  206. margin-top: #{6rpx};
  207. font-size: $uni-font-size-weak-two;
  208. }
  209. .card-btn-group {
  210. margin-top: #{34rpx};
  211. }
  212. .card-btn {
  213. width: #{284rpx};
  214. height: #{76rpx};
  215. &.btn-1 {
  216. margin: #{410rpx auto 0 auto};
  217. }
  218. &.btn-0 {
  219. &:first-child {
  220. margin-right: #{38rpx};
  221. }
  222. }
  223. }
  224. .card-modal {
  225. background-color: rgba(0, 0, 0, 0.5);
  226. width: 100%;
  227. height: 100%;
  228. position: fixed;
  229. top: 0;
  230. left: 0;
  231. z-index: 1000;
  232. .modal-content {
  233. width: #{600rpx};
  234. height: #{528rpx};
  235. background-size: contain;
  236. background-repeat: no-repeat;
  237. background-position: center;
  238. .error {
  239. margin: #{290rpx auto 0 auto};
  240. font-size: $uni-font-size-import-one;
  241. }
  242. .modal-btn {
  243. margin: #{62rpx auto 0 auto};
  244. width: #{520rpx};
  245. height: #{90rpx};
  246. border-radius: #{90rpx};
  247. }
  248. }
  249. }
  250. }
  251. </style>