Goodsonline.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <seller-base :show="false"><view style="position: absolute;top:0;right:0;left:0;bottom:0" class="scroll-view-wrapper div container">
  3. <view class="div common-header-wrap">
  4. <view class="status-holder"></view>
  5. <view :style="'height:'+navHeight+'px'"></view>
  6. <view class="common-header-holder"></view>
  7. <view class="common-header-fixed">
  8. <title-header />
  9. <uni-nav-bar title="商品管理" class="common-header" left-icon="back" @clickLeft="goBack()">
  10. </uni-nav-bar>
  11. </view>
  12. </view>
  13. <!-- header -->
  14. <view class="div order-header">
  15. <view class="div seller-search">
  16. <view class="div common-search">
  17. <view class="div field-line-right">
  18. <input class="field-input" v-model="keyword" placeholder="请输入您要搜索的商品" @confirm="getGoodsList()" />
  19. </view>
  20. </view>
  21. </view>
  22. <view class="ul">
  23. <view
  24. class="li item"
  25. v-for="item in orderNav"
  26. v-bind:key="item.id"
  27. v-bind:class="{ active: goods_type == item.id }"
  28. v-on:click="setOrderNavActive(item.id)"
  29. >
  30. {{ item.name }}
  31. </view>
  32. </view>
  33. </view>
  34. <view class="scroll-view div pb-30" style="position:relative">
  35. <scroll-view style="position: absolute;top:0;right:0;left:0;bottom:0" class="div" @scrolltolower="loadMore" scroll-y="true">
  36. <view class="div pb-30" v-if="goodsList.length > 0">
  37. <view class="div mb-5 goods-item" v-for="(item, index) in goodsList" :key="index">
  38. <view class="div goods-info">
  39. <view class="div p-img">
  40. <image mode="aspectFit" class="img" :src="item.goods_image"/>
  41. </view>
  42. <view class="div p-info">
  43. <view class="div name">{{item.goods_name}}</view>
  44. <view class="div line">
  45. <view class="div price">¥{{item.goods_price}}</view>
  46. <view class="div stock">库存:{{item.goods_storage_sum}}</view>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="div goods-btn" v-if="item.goods_lock == 0">
  51. <view class="div common-btn btn-2" @click="goods_edit(item.goods_commonid,item.gc_id)">编辑</view>
  52. <view class="div common-btn btn-2 ml-5" @click="goods_image(item.goods_commonid)">图片</view>
  53. <view class="div common-btn btn-2 ml-5" v-if="item.goods_state === 0" @click="goods_show(item.goods_commonid)">上架</view>
  54. <view class="div common-btn btn-2 ml-5" v-if="item.goods_state === 1" @click="goods_unshow(item.goods_commonid)">下架</view>
  55. <view class="div common-btn btn-1 ml-5" @click="drop_goods(item.goods_commonid)">删除</view>
  56. </view>
  57. <view class="div goods-btn" v-else>
  58. <view class="div common-btn btn-3">锁定</view>
  59. </view>
  60. </view>
  61. </view>
  62. <empty-record v-else></empty-record>
  63. </scroll-view>
  64. </view>
  65. <view class='common-add-btn-wrapper'><view class="div common-btn common-add-btn" @click="goods_add">新增</view></view>
  66. </view>
  67. <uni-popup background-color="#fff" ref="confirm" type="dialog">
  68. <uni-popup-dialog :mode="dialog.mode" :title="dialog.title" :content="dialog.content" :placeholder="dialog.content" @confirm="confirmDialog" @close="closeDialog"></uni-popup-dialog>
  69. </uni-popup>
  70. </seller-base>
  71. </template>
  72. <script>
  73. import {getFontSize} from '@/util/common'
  74. import TitleHeader from '../../TitleHeader'
  75. import { urlencode } from '@/util/common'
  76. import SellerBase from '../SellerBase'
  77. import EmptyRecord from '../../EmptyRecord'
  78. import { getGoodsList, dropGoods, goodsShow, goodsUnshow } from '../../../api/sellerGoods'
  79. import flexLine from '../../flexLine'
  80. export default {
  81. name: 'Goodsonline',
  82. computed:{
  83. fontSize(){
  84. return getFontSize()
  85. },
  86. },
  87. data(){
  88. return {
  89. navHeight: 0,
  90. dialog:{},
  91. controller:'Sellergoodsonline',
  92. params: { 'page': 0, 'per_page': 10 },
  93. loading: false, // 是否加载更多
  94. isMore: true, // 是否有更多
  95. pageTotal: 1, // 总页数
  96. goodsList: [], // 商品列表
  97. keyword: '',
  98. goods_type: '',
  99. search_type: '',
  100. orderNav: [
  101. {
  102. 'name': '出售中',
  103. 'id': ''
  104. },
  105. {
  106. 'name': '仓库中',
  107. 'id': 'offline'
  108. },
  109. {
  110. 'name': '待审核',
  111. 'id': 'waitverify'
  112. },
  113. {
  114. 'name': '违规商品',
  115. 'id': 'lockup'
  116. }
  117. ]
  118. }
  119. },
  120. components:{
  121. TitleHeader,
  122. SellerBase,
  123. flexLine,
  124. EmptyRecord
  125. },
  126. onShow () {
  127. this.reload()
  128. },
  129. mounted(){
  130. // #ifdef MP-WEIXIN
  131. this.navHeight = uni.getMenuButtonBoundingClientRect().height
  132. // #endif
  133. },
  134. methods:{
  135. closeDialog(){
  136. },
  137. confirmDialog(value){
  138. switch(this.dialog.condition){
  139. case 1:
  140. uni.showLoading({ title: '加载中' })
  141. goodsShow(this.controller,this.dialog.data).then(res => {
  142. uni.hideLoading()
  143. this.reload()
  144. }).catch(function (error) {
  145. uni.showToast({icon:'none',title: error.message})
  146. })
  147. break
  148. case 2:
  149. uni.showLoading({ title: '加载中' })
  150. goodsUnshow(this.controller,this.dialog.data).then(res => {
  151. uni.hideLoading()
  152. this.reload()
  153. }).catch(function (error) {
  154. uni.showToast({icon:'none',title: error.message})
  155. })
  156. break
  157. case 3:
  158. uni.showLoading({ title: '加载中' })
  159. dropGoods(this.controller,this.dialog.data).then(res => {
  160. uni.hideLoading()
  161. this.reload()
  162. }).catch(function (error) {
  163. uni.showToast({icon:'none',title: error.message})
  164. })
  165. break
  166. }
  167. },
  168. goBack(){uni.navigateBack({delta:1})},
  169. goods_add () {
  170. uni.navigateTo({url:'/pages/seller/goods/GoodsForm1'+'?'+urlencode({ action: 'add' })})
  171. },
  172. goods_image (commonid) {
  173. uni.navigateTo({url:'/pages/seller/goods/GoodsForm3'+'?'+urlencode({ commonid: commonid })})
  174. },
  175. goods_edit (commonid, class_id) {
  176. uni.navigateTo({url:'/pages/seller/goods/GoodsForm2'+'?'+urlencode({ commonid: commonid, class_id: class_id })})
  177. },
  178. setOrderNavActive (index) {
  179. this.goods_type = index
  180. if(index==''){
  181. this.controller='Sellergoodsonline'
  182. }else{
  183. this.controller='Sellergoodsoffline'
  184. }
  185. this.reload()
  186. },
  187. getGoodsList (ispush) {
  188. uni.showLoading({ title: '加载中' })
  189. let params = this.params
  190. getGoodsList(this.controller,params, this.keyword, this.goods_type, this.search_type).then(res => {
  191. uni.hideLoading()
  192. if (ispush) {
  193. this.goodsList = this.goodsList.concat(res.result.goods_list)
  194. } else {
  195. this.goodsList = res.result.goods_list
  196. }
  197. this.pageTotal = res.result.page_total
  198. if (res.result.hasmore) {
  199. this.isMore = true
  200. } else {
  201. this.isMore = false
  202. }
  203. }).catch(error=>{
  204. uni.hideLoading()
  205. uni.showToast({icon:'none',title: error.message})
  206. })
  207. },
  208. loadMore () {
  209. this.loading = true
  210. this.params.page = ++this.params.page
  211. if (this.isMore && this.params.page <= this.pageTotal) {
  212. this.loading = false
  213. this.getGoodsList(true)
  214. }
  215. },
  216. // 商品上架
  217. goods_show (goods_id) {
  218. this.dialog={condition:1,content:'您确定要上架此商品吗?',data:goods_id}
  219. this.$refs.confirm.open()
  220. },
  221. goods_unshow (goods_id) {
  222. this.dialog={condition:2,content:'您确定要下架此商品吗?',data:goods_id}
  223. this.$refs.confirm.open()
  224. },
  225. drop_goods (goods_id) {
  226. this.dialog={condition:3,content:'您确定要删除此商品吗?',data:goods_id}
  227. this.$refs.confirm.open()
  228. },
  229. reload () {
  230. // 重新加载数据
  231. this.params.page = 0
  232. this.isMore = true
  233. this.goodsList = []
  234. this.loadMore()
  235. }
  236. }
  237. }
  238. </script>
  239. <style scoped lang="scss">
  240. .scroll-view-wrapper{display: flex;flex-direction: column;}
  241. .scroll-view{flex:1}
  242. .common-header{
  243. .btn{background: #000;color: #fff;box-shadow: 0px 2px 4px #d2d2d2;}
  244. }
  245. .order-header {
  246. .ul {
  247. list-style: none;
  248. width: auto;
  249. display: flex;
  250. justify-content: space-around;
  251. align-content: center;
  252. align-items: center;
  253. height: 100%;
  254. background: rgba(255, 255, 255, 1);
  255. border-bottom: 1px solid #e8eaed;
  256. .li {
  257. font-size:$subFontSize;
  258. color: #333;
  259. height: 100%;
  260. text-align: center;
  261. line-height: 2.2rem;
  262. border-bottom: 0.1rem solid transparent;
  263. &.active {
  264. color: $primaryColor;
  265. border-bottom-color: $primaryColor;
  266. }
  267. }
  268. }
  269. }
  270. .goods-item{background:#fff;}
  271. .goods-info{height:4rem;padding:.5rem $pageSpace;}
  272. .goods-info .p-img{float:left}
  273. .goods-info .p-img .img{width:4rem;height:4rem;border-radius:.4rem;}
  274. .goods-info .p-info{margin-left:4.5rem;}
  275. .goods-info .p-info .line{display: flex;}
  276. .goods-info .p-info .name{height:2rem;line-height:1rem;font-size:$subFontSize;overflow:hidden;margin-bottom: 1rem}
  277. .goods-info .p-info .price{color:red;line-height:1rem;font-size:$subFontSize;flex:1}
  278. .goods-info .p-info .stock{line-height:1rem;font-size:$h6;color:#666}
  279. .goods-btn{padding:.5rem;display: flex;flex-direction: row;justify-content: flex-end;align-items: stretch;}
  280. .btn-1{border:1px solid $primaryColor;color:$primaryColor;min-width: 2rem}
  281. .btn-2{border:1px solid #333;color:#333;min-width: 2rem}
  282. .btn-3{border:1px solid #eee;color:#B3B6BD;min-width: 2rem}
  283. .seller-search {display: flex;height: 1.6rem;padding: 0.35rem $pageSpace;justify-content: space-between;align-items: center;background: #fff;.slot{width:1.6rem;font-size:1.2rem} }
  284. .seller-search .mint-cell{min-height:0}
  285. .seller-search .mint-cell:after{background-color:#fff!important;}
  286. .common-search{flex:1;height:1.4rem}
  287. .common-search input {box-sizing: border-box;width: 100%;height: 1.6rem;border-radius: 1.6rem;background: #EDEDED url(../../../static/image/home/icon_search.png) no-repeat 0.6rem center;background-size:0.55rem;font-size:$subFontSize;color: #999;padding-left:1.6rem;border: 0;}
  288. .right{width:2.6rem;height: 1.6rem;}
  289. </style>