微信

index.vue 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <div class="mainPage" v-if="show">
  3. <!-- <div class="residue">
  4. <i class="iconfont icon-gantanhao"></i>
  5. <span>仅剩{{data.TotalCount - data.UsedCount}}张券可以领取!</span>
  6. </div>
  7. <div class="logo">
  8. <img :src="logo" alt="">
  9. </div> -->
  10. <div class="banner" v-if="!video">
  11. <img :src="data.Images[0].CardImageUrl" alt="" width="100%" height="100%" v-if="type === 'card'">
  12. <img :src="data.Images[0].CouponImageUrl" alt="" width="100%" height="100%" v-if="type === 'coupon'">
  13. </div>
  14. <div class="content">
  15. <div class="title" v-if="$route.query.type === 'card'">{{data.CardName}}</div>
  16. <div class="title" v-else>{{data.CouponName}}</div>
  17. <div class="video" v-if='video'>
  18. <video :src="data.VideoUrl" width="100%" height="100%"></video>
  19. </div>
  20. <div class="text">
  21. <div>
  22. <i class="icon-shuoming iconfont"></i>
  23. <span>卡券使用说明</span>
  24. </div>
  25. <pre v-if="$route.query.type === 'card'">{{data.Share.CardUseInstruction}}</pre>
  26. <pre v-else>{{data.Share.UseInstruction}}</pre>
  27. </div>
  28. <div class="text">
  29. <div>
  30. <i class="icon-kaquan iconfont"></i>
  31. <span>卡券有效期</span>
  32. </div>
  33. <pre>有效期至{{toolClass.dateFormat(data.EndDate,'yyyy-MM-dd')}},请在有效期结束前使用, 过期作废;</pre>
  34. </div>
  35. <div class="text">
  36. <div>
  37. <i class="icon-dingwei iconfont"></i>
  38. <span>服务网点</span>
  39. </div>
  40. <pre>{{data.address}}</pre>
  41. </div>
  42. <div class="submit" v-if="button" @click="receive">确认领取</div>
  43. <div class="submit" v-else>点击右上角分享给客户</div>
  44. </div>
  45. </div>
  46. </template>
  47. <script>
  48. import wxsdk from '../../../util/share'
  49. import logo from '../../../common/icon/logoTop.png'
  50. import { createNamespacedHelpers } from 'vuex'
  51. const { mapState: mapShareState, mapActions: mapShareActions } = createNamespacedHelpers('share')
  52. const { mapState: mapAppState, mapActions: mapAppActions } = createNamespacedHelpers('app')
  53. export default {
  54. data () {
  55. return {
  56. logo,
  57. video: true,
  58. button: true,
  59. show: false,
  60. type: '',
  61. data: {}
  62. }
  63. },
  64. computed: {
  65. ...mapShareState({
  66. cardShare: x => x.cardShare,
  67. couponShare: x => x.couponShare
  68. }),
  69. ...mapAppState({
  70. caseList: x => x.CaseList
  71. })
  72. },
  73. created () {
  74. this.data = {}
  75. if (this.$route.params) {
  76. let that = this
  77. Object.keys(this.$route.params).forEach(function (key) {
  78. that.$route.query[key] = that.$route.params[key]
  79. })
  80. }
  81. this.type = this.$route.query.type
  82. if (this.$route.query.sharetype === 'share') {
  83. this.button = false
  84. }
  85. this.getCaseList().then(() => {
  86. this.init()
  87. })
  88. },
  89. methods: {
  90. ...mapShareActions(['getCardShare', 'getCouponShare', 'setCardShare', 'setCouponShare']),
  91. ...mapAppActions(['getCaseList']),
  92. init () {
  93. if (this.$route.query.type === 'card') {
  94. this.getCardShare({ id: this.$route.query.id }).then(() => {
  95. this.data = this.cardShare.Card
  96. this.data.address = this.caseList.filter(x => x.CaseId === this.data.CaseId)[0].CaseAddress
  97. if (!this.data.VideoUrl) {
  98. this.video = false
  99. }
  100. this.show = true
  101. this.sdk(this.data.Share.CardShareInfo)
  102. })
  103. } else {
  104. this.getCouponShare({ id: this.$route.query.id }).then(() => {
  105. this.data = this.couponShare.coupon
  106. this.data.address = this.caseList.filter(x => x.CaseId === this.data.CaseId)[0].CaseAddress
  107. if (!this.data.VideoUrl) {
  108. this.video = false
  109. }
  110. this.show = true
  111. this.sdk(this.data.Share.CouponShareInfo)
  112. })
  113. }
  114. },
  115. receive () {
  116. if (this.$route.query.type === 'card') {
  117. this.setCardShare({ id: this.$route.query.id, salesid: this.$route.query.salesid, serialcode: this.$route.query.random }).then(() => {
  118. this.$router.push({ name: 'receiveResults', query: { type: 'success', text: '卡券' } })
  119. }).catch((err) => {
  120. this.$router.push({ name: 'receiveResults', query: { type: 'fail' } })
  121. console.log(err)
  122. })
  123. } else {
  124. this.setCouponShare({ id: this.$route.query.id, salesid: this.$route.query.salesid, serialcode: this.$route.query.random }).then(() => {
  125. this.$router.push({ name: 'receiveResults', query: { type: 'success', text: '优惠券' } })
  126. }).catch((err) => {
  127. this.$router.push({ name: 'receiveResults', query: { type: 'fail' } })
  128. console.log(err)
  129. })
  130. }
  131. },
  132. sdk (info) {
  133. let logo, title
  134. if (this.$route.query.type === 'card') {
  135. logo = this.data.Images[0].CardImageUrl + '?x-oss-process=style/wxicon'
  136. title = this.data.CardName
  137. } else {
  138. logo = this.data.Images[0].CouponImageUrl + '?x-oss-process=style/wxicon'
  139. title = this.data.CouponName
  140. }
  141. wxsdk({ url: encodeURIComponent(window.location.href.split('#')[0]) }, {
  142. title: title,
  143. desc: info,
  144. link: `${window.location.origin}${window.location.pathname}#/receiveShared/${this.$route.query.id}/${this.$route.query.salesid}/${this.$route.query.type}/${this.$route.query.random}/receive`,
  145. thu_image: logo
  146. })
  147. }
  148. }
  149. }
  150. </script>
  151. <style lang="scss" scoped>
  152. @import 'page.scss';
  153. </style>