task-details.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view class="container clearfix">
  3. <tui-skeleton v-if="skeletonShow" backgroundColor="#fafafa" borderRadius="10rpx" :isLoading="true"
  4. :loadingType="5" />
  5. <view class="container-content tui-skeleton" v-else>
  6. <view class="empty-container" v-if="!taskInfo">
  7. <image class="empty-container-image" :src="StaticUrl + '/icon/icon-coupon-empty@2x.png'"></image>
  8. <text class="error-text">暂无推广信息~</text>
  9. </view>
  10. <template v-else>
  11. <view class="container-main">
  12. <view class="main-product" @click.stop="this.$api.navigateTo(`/pages/goods/product?id=${taskInfo.productId}`)">
  13. <view class="main-product-image">
  14. <image :src="taskInfo.mainImage" mode=""></image>
  15. </view>
  16. <view class="main-product-name">
  17. {{ taskInfo.productName }}
  18. </view>
  19. </view>
  20. <mp-html :content="html" :tag-style="tagStyle" />
  21. </view>
  22. </template>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import { mapState, mapMutations } from 'vuex'
  28. import wxLogin from '@/common/config/wxLogin.js'
  29. import authorize from '@/common/config/authorize.js'
  30. import { COUPON_TEXT_MAP } from '@/utils/coupon.share.js'
  31. import payMixins from '@/mixins/payMixins.js'
  32. export default {
  33. mixins: [payMixins],
  34. data() {
  35. return {
  36. StaticUrl: this.$Static,
  37. taskInfo: {},
  38. coupinList: [],
  39. payAmount: 100, //支付金额
  40. skeletonShow: true,
  41. isReceiveLoading: false, //领券操作状态
  42. html:'',
  43. param: {
  44. serviceProviderId: 0,
  45. userId: 0,
  46. taskId: 0
  47. }
  48. }
  49. },
  50. onLoad(option) {
  51. wxLogin.wxLoginAuthorize()
  52. this.param.serviceProviderId = option.shareSpid
  53. this.param.taskId = option.taskId
  54. // #ifdef MP-WEIXIN
  55. // 绑定分享参数
  56. console.log('绑定分享参数', { query: `taskId=${option.taskId}&shareSpid=${option.shareSpid}` })
  57. wx.onCopyUrl(() => {
  58. return { query: `taskId=${option.taskId}&shareSpid=${option.shareSpid}` }
  59. })
  60. // #endif
  61. this.getTaskDetail(this.param.taskId)
  62. },
  63. filters: {},
  64. computed: {
  65. ...mapState(['hasLogin', 'userInfo', ])
  66. },
  67. methods: {
  68. async getTaskDetail() {
  69. // 初始化推广任务详情
  70. try {
  71. const userInfo = await this.$api.getStorage()
  72. this.param.userId = userInfo.userId ? userInfo.userId : 0
  73. const res = await this.SellerService.getTaskDetail(this.param)
  74. this.taskInfo = res.data
  75. uni.setNavigationBarTitle({ title: `${this.taskInfo.title}` })
  76. this.html = this.$api.adaptRichTextImg(this.taskInfo.content)
  77. setTimeout(() => {
  78. this.skeletonShow = false
  79. }, 500)
  80. } catch (e) {
  81. console.log('初始化推广任务详情异常~')
  82. }
  83. }
  84. },
  85. onShareAppMessage(res) {
  86. //分享优惠券
  87. if (res.from === 'button') {
  88. // 来自页面内转发按钮
  89. }
  90. const task = this.taskInfo
  91. const path = `/pages/seller/task/task-details?taskId=${task.taskId}&shareSpid=${this.param.serviceProviderId}`
  92. return {
  93. title: task.title,
  94. path: path,
  95. imageUrl: task.topPic ? `${task.topPic}` : ''
  96. }
  97. },
  98. onHide() {
  99. // 取消绑定分享参数
  100. wx.offCopyUrl()
  101. },
  102. onShow() {
  103. }
  104. }
  105. </script>
  106. <style lang="scss">
  107. page {
  108. background-color: #f7f7f7;
  109. }
  110. .container {
  111. width: 100%;
  112. height: auto;
  113. }
  114. .empty-container-image {
  115. width: 260rpx;
  116. height: 260rpx;
  117. margin-top: -300rpx;
  118. }
  119. .container-main {
  120. box-sizing: border-box;
  121. padding: 24rpx;
  122. .main-product{
  123. width: 100%;
  124. height: 220rpx;
  125. border-radius: 16rpx;
  126. background: #ffffff;
  127. background-size: cover;
  128. overflow: hidden;
  129. box-sizing: border-box;
  130. padding: 20rpx;
  131. display: flex;
  132. flex-direction: row;
  133. justify-content: flex-start;
  134. margin-bottom: 20rpx;
  135. .main-product-image{
  136. width: 180rpx;
  137. height: 180rpx;
  138. border-radius: 16rpx;
  139. overflow: hidden;
  140. box-sizing: border-box;
  141. border: 1px solid #f7f7f7;
  142. image{
  143. width: 178rpx;
  144. height: 178rpx;
  145. display: block;
  146. }
  147. }
  148. .main-product-name{
  149. width: 500rpx;
  150. padding-left: 24rpx;
  151. box-sizing: border-box;
  152. font-size: $font-size-28;
  153. color: #333333;
  154. line-height: 48rpx;
  155. }
  156. }
  157. text{
  158. display: inline-block;
  159. width: 702rpx !important;
  160. text-align: justify;
  161. font-size: 28rpx;
  162. color: #666666;
  163. line-height: 48rpx;
  164. }
  165. }
  166. /*富文本样式*/
  167. rich-text {
  168. width: 702rpx !important;
  169. padding: 0 20rpx;
  170. text-align: justify;
  171. font-size: 28rpx;
  172. color: #666666;
  173. line-height: 50rpx;
  174. }
  175. rich-text.p {
  176. width: 702rpx !important;
  177. padding: 0 20rpx;
  178. text-align: justify;
  179. font-size: 28rpx;
  180. color: #666666;
  181. line-height: 50rpx;
  182. }
  183. rich-text._img {
  184. width: 100%;
  185. height: auto;
  186. }
  187. rich-text image {
  188. width: 100%;
  189. height: auto;
  190. }
  191. </style>