goods.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <view class="goods main-bg">
  3. <view class="header font-color2 font-thirty" @click="goto">添加商品</view>
  4. <view class="title font-color3 font-thirty-two" v-if="list.length > 0">当前主营商品</view>
  5. <view class="list" v-if="list.length > 0">
  6. <view class="item" v-for="item in list" @click="handleGoods(item)">
  7. <image class="img" :src="image(item.goodsPic)"></image>
  8. <view class="name font-color3 font-twenty ellipsis">{{ item.goodsName }}</view>
  9. <view class="jia ellipsis">
  10. <span class="yuan font-color2 font-twenty">¥{{ item.goodsRatePrice }}</span>
  11. <!-- <span class="hui font-color5 font-twenty-four">惠军价: ¥{{ item.goodsPrice }}</span> -->
  12. </view>
  13. </view>
  14. </view>
  15. <view class="empty" v-else>
  16. <u-empty text="暂无商品" mode="list"></u-empty>
  17. </view>
  18. <u-tabbar :list="tabBarList" :active-color="activeColor" :inactive-color="inactiveColor"
  19. :border-top="borderTop"></u-tabbar>
  20. </view>
  21. </template>
  22. <script>
  23. import server from "@/api/index";
  24. import { mapGetters } from 'vuex'
  25. import http from '@/common/http.js'
  26. export default {
  27. data() {
  28. return {
  29. borderTop: false,
  30. inactiveColor: '#ccc',
  31. activeColor: '#2E4F1C',
  32. list:[],
  33. userInfo: {}
  34. }
  35. },
  36. computed: {
  37. ...mapGetters([
  38. 'tabBarList',
  39. 'role'
  40. ])
  41. },
  42. onLoad() {
  43. setTimeout(function () {
  44. }, 1000);
  45. uni.startPullDownRefresh();
  46. },
  47. onPullDownRefresh() {
  48. this.userInfo = uni.getStorageSync('userInfo');
  49. this.getListFn(this.userInfo.nickName);
  50. setTimeout(function () {
  51. uni.stopPullDownRefresh();
  52. }, 1000);
  53. },
  54. onShow() {
  55. this.userInfo = uni.getStorageSync('userInfo');
  56. this.getListFn(this.userInfo.nickName);
  57. },
  58. methods:{
  59. handleGoods(item){
  60. uni.navigateTo({
  61. url: '/pages/merchant/goods/add?id='+ item.goodsId
  62. })
  63. },
  64. image(e) {
  65. return http.webUrl + e
  66. },
  67. getListFn(id){
  68. server.getGoodsInfo({shopsId: id, goodsStatus :'2'}).then(res =>{
  69. this.list = [];
  70. if(res){
  71. this.list = res
  72. }
  73. })
  74. },
  75. goto(){
  76. uni.navigateTo({
  77. url: '/pages/merchant/goods/add'
  78. })
  79. }
  80. }
  81. }
  82. </script>
  83. <style lang="scss" scoped>
  84. .goods{
  85. width: 100%;
  86. height: auto;
  87. min-height: 100vh;
  88. padding: 30rpx;
  89. .header{
  90. width: 100%;
  91. height: 96rpx;
  92. line-height: 96rpx;
  93. border-radius: 48rpx;
  94. text-align: center;
  95. border: 1rpx solid #2E4F1C;
  96. font-weight: 600;
  97. }
  98. .title{
  99. height: 115rpx;
  100. line-height: 115rpx;
  101. }
  102. .empty{
  103. padding-top: 200rpx;
  104. }
  105. .list{
  106. width: 100%;
  107. display: flex;
  108. flex-wrap: wrap;
  109. justify-content: space-between;
  110. .item{
  111. width: calc(50% - 15rpx);
  112. height: 370rpx;
  113. margin-bottom: 30rpx;
  114. background: #FFFFFF;
  115. .img{
  116. width: 100%;
  117. height: 228rpx;
  118. }
  119. .name{
  120. width: calc(100% - 30rpx);
  121. padding-left: 30rpx;
  122. height: 85rpx;
  123. line-height: 85rpx;
  124. }
  125. .jia{
  126. width: calc(100% - 30rpx);
  127. padding-left: 20rpx;
  128. }
  129. .hui{
  130. padding-left: 20rpx;
  131. }
  132. }
  133. }
  134. }
  135. </style>