replaceGoods.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <view>
  3. <view class="main">
  4. <view class="mainLine">
  5. <view class="goodsItem" v-for="(v,i) in list.goodsList" v-if='v.showr' @click="goGoods(v)">
  6. <view>
  7. <image :src="v.picUrl" mode="" class="goodsImg" v-if="v.picUrl"></image>
  8. <image src="../../static/img/noimg.png" mode="" class="goodsImg" v-else></image>
  9. </view>
  10. <view class="goodsItemRight">
  11. <view class="goodsItemName">{{v.showName}}</view>
  12. <view class="goodsItemBottom">
  13. <view class="goodssalePrice">
  14. <span>¥{{v.salePrice?v.salePrice:'-'}}</span>
  15. <!-- <span class="goodsNum">x{{v.qty}}</span> -->
  16. </view>
  17. <view class="replaceBtn" @click.stop="replace(v)">更换</view>
  18. </view>
  19. </view>
  20. </view>
  21. <nodata v-if="list.length==0&&isload"></nodata>
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import nodata from '@/components/nodata/nodata.vue'
  28. export default {
  29. components: {
  30. nodata
  31. },
  32. data() {
  33. return {
  34. title: 'Hello',
  35. packageGoodsID:'',
  36. shopId:'',
  37. list:'',
  38. isload:false,
  39. }
  40. },
  41. onLoad(opt) {
  42. /* this.packageGoodsID=opt.packageGoodsID; */
  43. this.shopId=uni.getStorageSync("shopData").shopId;
  44. this.list=uni.getStorageSync("replaceDataList")
  45. //this.getData()
  46. this.list.goodsList.forEach((item,index1)=>{
  47. item.qty=1
  48. })
  49. const resdata = new Map()
  50. this.list.goodsList= this.list.goodsList.filter((item) => !resdata.has(item.goodsID) && resdata.set(item.goodsID, 1))
  51. },
  52. methods: {
  53. getData(){
  54. uni.showLoading({
  55. title: '加载中'
  56. })
  57. this.$http('miniApp/packageMiniAppController/queryPackageReplaceGoods', {
  58. packageGoodsID:this.packageGoodsID,
  59. shopID:this.shopId
  60. },'GET').then(res => {
  61. uni.hideLoading();
  62. this.isload=true;
  63. this.list=res.data;
  64. })
  65. },
  66. replace(v){
  67. console.log(v)
  68. /* if(v.listImg.length>0){
  69. v.picUrl=v.listImg[0].url
  70. } */
  71. uni.setStorage({
  72. key: 'replaceData',
  73. data: v,
  74. success: function () {
  75. uni.navigateBack({
  76. delta:1
  77. })
  78. }
  79. });
  80. },
  81. goGoods(item){
  82. /* uni.setStorage({
  83. key: 'goodsreplaceData',
  84. data: item,
  85. success: function () {
  86. uni.navigateBack({
  87. delta:1
  88. })
  89. uni.navigateTo({
  90. url:'../module/goodsDetail?goodsId='+item.goodsID+'&type=1'+'&typeIndex=2&maintain=2'
  91. })
  92. }
  93. }); */
  94. },
  95. login(){
  96. uni.navigateTo({
  97. url:'../login/login'
  98. })
  99. }
  100. }
  101. }
  102. </script>
  103. <style scoped>
  104. .main{
  105. padding: 24rpx;
  106. }
  107. .mainLine{
  108. }
  109. .goodsItem{
  110. display: flex;
  111. padding: 30rpx 0;
  112. border-bottom: 1px solid #EEEEEE;
  113. }
  114. .goodsItem:last-child{
  115. border: none;
  116. }
  117. .goodsItemRight{
  118. width: 520rpx;
  119. padding-left: 20rpx;
  120. display: flex;
  121. flex-direction:column;
  122. justify-content: space-between;
  123. }
  124. .goodsItemBottom{
  125. display: flex;
  126. justify-content: space-between;
  127. }
  128. .goodsItemName{
  129. font-size: 26rpx;
  130. color: #3C3C3C;
  131. }
  132. .goodssalePrice{
  133. font-size: 32rpx;font-weight: 500;color: #FF4F00;
  134. }
  135. .goodsNum{
  136. font-size: 24rpx;font-weight: 400;color: #999999;
  137. padding-left: 50rpx;
  138. }
  139. .goodsImg{
  140. width: 120rpx;height: 120rpx;
  141. }
  142. .replaceBtn{
  143. color: #FF4F00;
  144. font-size:24rpx;}
  145. </style>