liveDetail.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <template>
  2. <view class="container">
  3. <view class="popup-open" @click="popupShow = true">
  4. <view class="iconfont iconzhibo-shangpin"></view>
  5. </view>
  6. <u-popup v-model="popupShow" mode="bottom">
  7. <view class="popup-box">
  8. <view class="popup-close" @click="popupShow = false">收起</view>
  9. <view class="popup-edit" @click="bindGood()">绑定</view>
  10. <scroll-view scroll-y="true" class="good-select-box">
  11. <view class="select-good-row" v-for="(item, index) in goodList" :key="index">
  12. <view class="good-check">
  13. <view class="iconfont" :class="item.check ? 'iconqueding' : 'iconfeigouxuan'" @click="item.check = !item.check"></view>
  14. </view>
  15. <view class="good-card" style="width: calc(100% - 60px);">
  16. <cover-image class="goods-img" :src="item.imgPath"></cover-image>
  17. <view class="good-info">
  18. <view class="good-name">{{item.productName}}</view>
  19. <view class="good-text">销量:{{item.sellCount}}</view>
  20. <view class="good-price">
  21. <text class="goods-spec">¥{{item.bizPrice}}/{{item.unit}}</text>
  22. <text class="goods-original">原价:{{item.originalPrice}}</text>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </scroll-view>
  28. </view>
  29. </u-popup>
  30. <u-top-tips ref="uTips"></u-top-tips>
  31. </view>
  32. </template>
  33. <script>
  34. const NET = require('@/utils/request')
  35. const API = require('@/config/api')
  36. export default {
  37. data() {
  38. return {
  39. liveId: '',
  40. popupShow: false,
  41. goodList: [],
  42. }
  43. },
  44. onLoad(options) {
  45. this.liveId = options.liveId
  46. NET.request(API.getBindedLiveGoods, {
  47. liveId: this.liveId
  48. }, 'GET').then(res => {
  49. let goodsIds = res.data.map(site => {
  50. return site.productId
  51. }).join(',')
  52. this.getAllGoods(goodsIds)
  53. }).catch(res => {
  54. this.$refs.uTips.show({
  55. title: '获取已绑定商品失败',
  56. type: 'warning',
  57. })
  58. })
  59. },
  60. methods: {
  61. // 获取可绑定商品
  62. getAllGoods(goodsIds) {
  63. NET.request(API.getVideoGoods, {}, 'GET').then(res => {
  64. res.data.forEach(site => {
  65. site.check = goodsIds.indexOf(site.productId) != -1
  66. })
  67. this.goodList = res.data
  68. }).catch(res => {
  69. this.$refs.uTips.show({
  70. title: '获取可绑定商品失败',
  71. type: 'warning',
  72. })
  73. })
  74. },
  75. // 绑定商品
  76. bindGood() {
  77. NET.request(API.bindLiveGoods, {
  78. liveId: this.liveId,
  79. prudoctIds: this.goodList.filter(site => site.check).map(site => {
  80. return site.productId
  81. })
  82. }, 'POST').then(res => {
  83. this.$refs.uTips.show({
  84. title: '绑定商品成功',
  85. type: 'success',
  86. })
  87. }).catch(res => {
  88. this.$refs.uTips.show({
  89. title: '绑定商品失败',
  90. type: 'warning',
  91. })
  92. })
  93. },
  94. },
  95. }
  96. </script>
  97. <style lang="less" scoped>
  98. page {
  99. width: 100%;
  100. height: 100%;
  101. }
  102. .container {
  103. width: 100%;
  104. height: 100%;
  105. float: left;
  106. position: relative;
  107. .popup-open {
  108. width: 50px;
  109. height: 50px;
  110. position: fixed;
  111. bottom: 15px;
  112. right: 15px;
  113. background: #52A63A;
  114. border-radius: 50%;
  115. text-align: center;
  116. line-height: 50px;
  117. .iconzhibo-shangpin {
  118. color: #FFFFFF;
  119. font-size: 34px;
  120. }
  121. }
  122. .popup-box {
  123. width: 100%;
  124. height: 400px;
  125. float: left;
  126. background-color: #FFFFFF;
  127. border-radius: 15px 15px 0px 0px;
  128. box-sizing: border-box;
  129. padding: 16px 0 0 0;
  130. position: relative;
  131. .popup-close {
  132. width: 50%;
  133. height: 26px;
  134. float: left;
  135. box-sizing: border-box;
  136. padding: 10px 15px 0 15px;
  137. font-size: 15px;
  138. font-family: PingFang SC;
  139. color: #52A63A;
  140. line-height: 16px;
  141. margin-bottom: 10px;
  142. }
  143. .popup-edit {
  144. width: 50%;
  145. height: 26px;
  146. float: right;
  147. box-sizing: border-box;
  148. padding: 10px 15px 0 15px;
  149. font-size: 15px;
  150. font-family: PingFang SC;
  151. color: #52A63A;
  152. line-height: 16px;
  153. margin-bottom: 10px;
  154. text-align: right;
  155. }
  156. .good-select-box {
  157. width: 100%;
  158. height: 400px;
  159. float: left;
  160. overflow-y: auto;
  161. padding: 40px 0 10px 0;
  162. }
  163. .select-good-row {
  164. width: 100%;
  165. height: 114px;
  166. float: left;
  167. }
  168. .good-check {
  169. width: 30px;
  170. height: 104px;
  171. float: left;
  172. line-height: 104px;
  173. margin-right: 10px;
  174. .iconfont {
  175. font-size: 40px;
  176. text-align: right;
  177. color: #51A539;
  178. }
  179. }
  180. .good-card {
  181. width: 100%;
  182. float: left;
  183. margin: 5px;
  184. background: #FFFFFF;
  185. border-radius: 15px;
  186. box-shadow: 0px 1px 5px 0px rgba(102, 102, 102, 0.43);
  187. padding: 12px;
  188. box-sizing: border-box;
  189. .goods-img {
  190. width: 80px;
  191. height: 80px;
  192. float: left;
  193. border-radius: 10px;
  194. object-fit: cover;
  195. }
  196. .good-info {
  197. width: calc(100% - 86px);
  198. height: 80px;
  199. float: right;
  200. .good-name {
  201. width: 100%;
  202. height: 40px;
  203. float: left;
  204. font-size: 15px;
  205. font-family: PingFang SC;
  206. color: #333333;
  207. line-height: 20px;
  208. overflow: hidden;
  209. text-overflow: ellipsis;
  210. display: -webkit-box;
  211. -webkit-line-clamp: 2;
  212. -webkit-box-orient: vertical;
  213. word-wrap: break-word;
  214. }
  215. .good-price {
  216. width: 100%;
  217. height: 20px;
  218. float: left;
  219. line-height: 20px;
  220. font-family: PingFang SC;
  221. white-space: nowrap;
  222. margin: 3px 0 3px 0;
  223. .goods-spec {
  224. font-size: 15px;
  225. color: #52A63A;
  226. margin-right: 6px;
  227. }
  228. .goods-original {
  229. font-size: 12px;
  230. text-decoration: line-through;
  231. color: #A67954;
  232. }
  233. }
  234. }
  235. }
  236. }
  237. }
  238. </style>