poster.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <app-layout>
  3. <view id="head" class="head">
  4. <view class="poster main-center cross-center" :style="{'background-image': `url(${info.poster_bg})`}">
  5. <view class="dir-top-nowrap main-center user">
  6. <image :src="info.avatar"></image>
  7. <view>{{info.nickname}}</view>
  8. </view>
  9. <view class="dir-left-nowrap info" v-if="coupon_id > 0">
  10. <view class="main-center cross-center discout" v-if="info.type == 1">{{info.discount}}<text>折</text></view>
  11. <view class="main-center cross-center discout" v-if="info.type == 2"><text>¥</text>{{info.sub_price}}</view>
  12. <view class="use-info dir-top-nowrap main-center cross-center">
  13. <view v-if="info.min_price || info.min_price == 0" class="min-price">{{info.min_price == 0 ? '无门槛使用' : '满'+ info.min_price +'可用'}}</view>
  14. <view v-if="info.discount_limit">优惠上限:¥{{info.discount_limit}}</view>
  15. <view>{{info.appoint_type}}</view>
  16. </view>
  17. </view>
  18. <view class="expire" v-if="coupon_id > 0 && info.expire_type">
  19. <text>
  20. <text>有效期:</text>
  21. <text v-if="info.expire_type == '2'">{{info.begin_time}} - {{info.end_time}}</text>
  22. <text v-else-if="info.expire_day > 0">领取后{{info.expire_day}}天内有效</text>
  23. </text>
  24. </view>
  25. <view class="dir-left-nowrap cross-center info" v-if="card_id > 0">
  26. <image class="card-pic" :src="info.pic_url"></image>
  27. <view class="name t-omit-two">{{info.name}}</view>
  28. </view>
  29. <image class="qrcode" :src="info.qrcode"></image>
  30. </view>
  31. </view>
  32. <view class="button main-center cross-center" @click="submitSave"
  33. :style="{'background-color': getTheme.background}">保存图片
  34. </view>
  35. </app-layout>
  36. </template>
  37. <script>
  38. import { mapState,mapGetters } from "vuex";
  39. export default {
  40. data() {
  41. return {
  42. card_id: 0,
  43. coupon_id: 0,
  44. info: {},
  45. }
  46. },
  47. computed: {
  48. ...mapGetters('mallConfig', {
  49. getTheme: 'getTheme',
  50. }),
  51. ...mapState({
  52. poster_img: state => state.mallConfig.__wxapp_img.poster,
  53. })
  54. },
  55. methods: {
  56. submitSave() {
  57. this.$showLoading({text: '生成中'});
  58. let that = this;
  59. let url;
  60. let para;
  61. if(that.card_id > 0) {
  62. url = that.$api.poster.card_share;
  63. para = {
  64. cardId: that.card_id
  65. }
  66. }
  67. if(that.coupon_id > 0) {
  68. url = that.$api.poster.coupon_share;
  69. para = {
  70. coupon_id: that.coupon_id
  71. }
  72. }
  73. that.$request({
  74. url: url,
  75. data: para
  76. }).then(info => {
  77. this.$hideLoading();
  78. let { code, data, msg } = info;
  79. if (code === 0) {
  80. const pic_url = data.pic_url;
  81. this.$utils.batchSave(pic_url, 'image').then(() => {
  82. uni.showToast({title: '保存成功'});
  83. });
  84. } else {
  85. uni.showToast({title: msg, icon: 'none'});
  86. }
  87. }).catch(() => {
  88. this.$hideLoading();
  89. })
  90. },
  91. getList() {
  92. let that = this;
  93. let url;
  94. let para;
  95. if(that.card_id > 0) {
  96. url = that.$api.poster.card;
  97. para = {
  98. cardId: that.card_id
  99. }
  100. }
  101. if(that.coupon_id > 0) {
  102. url = that.$api.poster.coupon;
  103. para = {
  104. coupon_id: that.coupon_id
  105. }
  106. }
  107. that.$request({
  108. url: url,
  109. data: para
  110. }).then(response=>{
  111. if(response.code == 0) {
  112. that.info = response.data;
  113. }else {
  114. that.$hideLoading();
  115. uni.showToast({
  116. title: response.msg,
  117. icon: 'none',
  118. duration: 1000
  119. });
  120. }
  121. }).catch(response => {
  122. that.$hideLoading();
  123. });
  124. },
  125. },
  126. onLoad(options) { this.$commonLoad.onload(options);
  127. let that = this;
  128. if(options.card_id > 0) {
  129. that.card_id = options.card_id
  130. }
  131. if(options.coupon_id > 0) {
  132. that.coupon_id = options.coupon_id
  133. }
  134. that.getList();
  135. }
  136. }
  137. </script>
  138. <style scoped lang="scss">
  139. .head {
  140. width: 100%;
  141. .poster {
  142. margin: #{50rpx} auto;
  143. width: #{600rpx};
  144. height: #{1067.2rpx};
  145. background-size: 100% 100%;
  146. background-position: center;
  147. background-repeat: no-repeat;
  148. position: relative;
  149. .user {
  150. position: absolute;
  151. top: 52.8rpx;
  152. left: 0;
  153. right: 0;
  154. width: 90%;
  155. margin: 0 auto;
  156. color: #fff;
  157. font-size: 24rpx;
  158. text-align: center;
  159. image {
  160. border-radius: 50%;
  161. width: 104rpx;
  162. height: 104rpx;
  163. margin: 0 auto 20rpx;
  164. }
  165. }
  166. .info {
  167. position: absolute;
  168. top: 274.8rpx;
  169. left: 0;
  170. color: #fff;
  171. height: 156rpx;
  172. width: 100%;
  173. .card-pic {
  174. width: 96rpx;
  175. height: 96rpx;
  176. border-radius: 50%;
  177. margin: 0 19.2rpx 0 60.8rpx;
  178. }
  179. .name {
  180. width: 264rpx;
  181. color: #353535;
  182. font-size: 27rpx;
  183. }
  184. .discout {
  185. width: 228.8rpx;
  186. font-size: 48rpx;
  187. text {
  188. font-size: 27rpx;
  189. margin-top: 14rpx;
  190. }
  191. }
  192. .use-info {
  193. color: #353535;
  194. font-size: 24rpx;
  195. view {
  196. margin: 5rpx 0;
  197. width: 100%;
  198. }
  199. .min-price {
  200. font-size: 27rpx;
  201. }
  202. }
  203. }
  204. .expire {
  205. position: absolute;
  206. bottom: 320rpx;
  207. left: 0;
  208. text-align: center;
  209. width: 100%;
  210. >text {
  211. border-radius: 24rpx;
  212. background-color: rgba(0,0,0,.2);
  213. padding: 9rpx 19.2rpx;
  214. color: #fff;
  215. font-size: 20rpx;
  216. }
  217. }
  218. .qrcode {
  219. position: absolute;
  220. bottom: 110rpx;
  221. left: 0;
  222. right: 0;
  223. width: 192rpx;
  224. height: 192rpx;
  225. margin: 0 auto;
  226. border-radius: 50%;
  227. }
  228. }
  229. }
  230. .button {
  231. font-size: #{32rpx};
  232. border-radius: #{40rpx};
  233. height: #{68rpx};
  234. margin: 0 auto #{50rpx};
  235. color: #ffffff;
  236. width: #{500rpx};
  237. }
  238. </style>