index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. <template>
  2. <view class="container-shop">
  3. <navbar :config="config" backColor="#666666"></navbar>
  4. <view class="top-nav" :style="{'top': stickyHeight + 'px'}">
  5. <view class="tabs">
  6. <view class="tab" :class="{'activeTab': currentTab == index}" v-for="(item, index) in tabs" :key="item.i"
  7. @click="changeTab(index)">
  8. {{item.label}}
  9. </view>
  10. </view>
  11. <view class="popup">
  12. <view class="item" @click="classifyPopup = true">
  13. <view class="text">{{typeId === '' ? '全部分类' : classifyList[classsIndex].name}}</view>
  14. <view class="iconfont3 icon">&#xe65e;</view>
  15. </view>
  16. <view class="item" @click="typePopup = true">
  17. <view class="text">{{type === '' ? '全部类型' : typeList[typeIndex].label}}</view>
  18. <view class="iconfont3 icon">&#xe65e;</view>
  19. </view>
  20. </view>
  21. </view>
  22. <view :style="{'height': headerHeight + 'px'}"></view>
  23. <view class="main">
  24. <template v-if="goodsList && goodsList.length">
  25. <view class="goodsitem" v-for="item in goodsList" :key="item.id">
  26. <view class="goods-title">
  27. <view class="goods-name">{{item.name}}({{item.type == 0 ? '商品' : '服务'}})</view>
  28. <view class="time">更新时间 {{item.update_time}}</view>
  29. </view>
  30. <shop-goods :goodsDetail="item"></shop-goods>
  31. <view class="goods-tools">
  32. <view class="btn" @click="isUp(item)">{{item.is_up == 1 ? '下架' : '上架'}}</view>
  33. <template v-if="item.is_up == 0">
  34. <view class="btn edit" @click="edit(item)">编辑</view>
  35. <view class="btn del" @click="del(item)">
  36. <view class="iconfont3 icon">&#xe8b6;</view>删除
  37. </view>
  38. </template>
  39. </view>
  40. </view>
  41. <u-loadmore :status="status" />
  42. </template>
  43. <noData v-if="goodsList.length<=0"></noData>
  44. </view>
  45. <view class="footer">
  46. <view class="online-btn btn" @click="classifyMent">分类管理</view>
  47. <view class="btn" @click="releaseGoods">发布商品</view>
  48. </view>
  49. <u-picker mode="selector" v-model="classifyPopup" :range="classifyList" range-key="name"
  50. :default-selector="[classsIndex]" @confirm="confirmClassifySelect"></u-picker>
  51. <u-picker mode="selector" v-model="typePopup" :range="typeList" range-key="label" :default-selector="[typeIndex]"
  52. @confirm="confirmTypeSelect"></u-picker>
  53. </view>
  54. </template>
  55. <script>
  56. import noData from "@/components/noData/nodata.vue"
  57. import shopGoods from "@/components/shop-goods.vue";
  58. export default {
  59. components: {
  60. noData,
  61. shopGoods
  62. },
  63. data() {
  64. return {
  65. config: {
  66. back: true,
  67. title: '商品管理',
  68. color: '#1A1A1A',
  69. backgroundColor: [1, "#fff"],
  70. statusBarFontColor: '#1A1A1A',
  71. leftSlot: true
  72. },
  73. headerHeight: 0,
  74. stickyHeight: 0,
  75. tabs: [{
  76. label: '已上架',
  77. i: 0,
  78. },
  79. {
  80. label: '已下架',
  81. i: 1,
  82. }
  83. ],
  84. currentTab: 0,
  85. classifyList: [],
  86. typeId: '',
  87. type: '',
  88. classifyPopup: false,
  89. typePopup: false,
  90. classsIndex: 0,
  91. typeIndex: 0,
  92. typeList: [{
  93. label: '全部类型',
  94. value: 0,
  95. type: ''
  96. },
  97. {
  98. label: '商品',
  99. value: 1,
  100. type: 0
  101. },
  102. {
  103. label: '服务',
  104. value: 2,
  105. type: 1
  106. }
  107. ],
  108. goodsList: [],
  109. params: {
  110. page: 1,
  111. limit: 10
  112. },
  113. totalPage: 0,
  114. currPage: 1,
  115. refresh: false,
  116. status: 'loadmore',
  117. }
  118. },
  119. onShow() {
  120. this.getGoodsClassify()
  121. this.getGoodsList(true)
  122. this.$nextTick(() => {
  123. let sysInfo = uni.getSystemInfoSync()
  124. this.$u.getRect('.top-nav').then(res => {
  125. this.headerHeight = res.height
  126. this.stickyHeight = sysInfo.statusBarHeight + 44
  127. })
  128. })
  129. },
  130. onPullDownRefresh() {
  131. this.getGoodsList(true)
  132. setTimeout(() => {
  133. uni.stopPullDownRefresh();
  134. }, 1000);
  135. },
  136. onReachBottom() {
  137. if (this.currPage == this.totalPage) {
  138. return this.status = 'nomore';
  139. } else {
  140. this.params.page++
  141. this.getGoodsList(false)
  142. }
  143. },
  144. methods: {
  145. // 获取店铺信息
  146. getShopInfo() {
  147. this.$http.get('/yxt/shop/my-shop', {
  148. union_business: true
  149. }).then(res => {
  150. if (res.code == 200 && res.data) {
  151. }
  152. })
  153. },
  154. // 获取商品分类
  155. getGoodsClassify() {
  156. this.$http.get('/offlinetype/goods/my_list', {
  157. isGoods: 1
  158. }).then(res => {
  159. if (res.code == 200) {
  160. if (res.list.length > 0) {
  161. this.classifyList = [{
  162. id: '',
  163. name: '全部分类'
  164. }, ...res.list]
  165. }
  166. }
  167. })
  168. },
  169. // 获取商品
  170. getGoodsList(refresh) {
  171. this.params.page = refresh ? 1 : this.params.page
  172. this.$http.get('/offline/goods/my_page', {
  173. isUp: this.currentTab == 0 ? 1 : 0,
  174. type: this.type,
  175. typeId: this.typeId,
  176. isGoods: 1,
  177. ...this.params
  178. }).then(res => {
  179. if (res.code == 200) {
  180. if (this.params.page == 1) this.goodsList = []
  181. this.goodsList = [...this.goodsList, ...res.page.list]
  182. this.totalPage = res.page.totalPage
  183. this.currPage = res.page.currPage
  184. if (this.currPage == this.totalPage) this.status = 'nomore';
  185. }
  186. })
  187. },
  188. changeTab(i) {
  189. if (this.currentTab == i) {
  190. return false
  191. }
  192. this.currentTab = i
  193. this.getGoodsList(true)
  194. },
  195. confirmClassifySelect(e) {
  196. this.classsIndex = e[0]
  197. this.typeId = this.classifyList[e[0]].id
  198. this.getGoodsList(true)
  199. },
  200. confirmTypeSelect(e) {
  201. this.typeIndex = e[0]
  202. this.type = this.typeList[e[0]].type
  203. this.getGoodsList(true)
  204. },
  205. isUp(item) {
  206. this.$http.put(`/offline/goods/upOrOffShelf/${item.id}`).then(res => {
  207. if (res.code == 200) {
  208. this.$mUtil.toast(item.is_up == 1 ? '下架成功' : '上架成功')
  209. this.getGoodsList(true)
  210. }
  211. })
  212. },
  213. edit(item) {
  214. uni.navigateTo({
  215. url: `/pages/workbench/goods/release?goodsId=${item.id}`
  216. })
  217. },
  218. del(item) {
  219. uni.showModal({
  220. title: '提示',
  221. content: '确定删除此商品?',
  222. success: (res) => {
  223. if (res.confirm) {
  224. this.$http.delete(`/offline/goods/delete/${item.id}`).then(res => {
  225. if (res.code == 200) {
  226. this.$mUtil.toast('删除成功')
  227. this.getGoodsList(true)
  228. }
  229. })
  230. console.log('用户点击确定');
  231. } else if (res.cancel) {
  232. console.log('用户点击取消');
  233. }
  234. }
  235. });
  236. },
  237. classifyMent() {
  238. uni.navigateTo({
  239. url: `/pages/workbench/goods/classify`
  240. })
  241. },
  242. releaseGoods() {
  243. uni.navigateTo({
  244. url: `/pages/workbench/goods/release`
  245. })
  246. }
  247. }
  248. }
  249. </script>
  250. <style>
  251. page {
  252. background-color: #fff;
  253. }
  254. </style>
  255. <style lang="scss" scoped>
  256. .container-shop {
  257. .top-nav {
  258. position: fixed;
  259. width: 100%;
  260. z-index: 9;
  261. background-color: #fff;
  262. .tabs {
  263. display: flex;
  264. justify-content: space-between;
  265. align-items: center;
  266. height: 76rpx;
  267. padding: 0 198rpx;
  268. border: 1rpx solid #f2f2f2;
  269. .tab {
  270. position: relative;
  271. height: 100%;
  272. line-height: 76rpx;
  273. font-size: 32rpx;
  274. font-family: PingFang SC, PingFang SC-Bold;
  275. font-weight: 700;
  276. text-align: center;
  277. color: #1a1a1a;
  278. }
  279. .activeTab {
  280. color: #FA6138;
  281. &::after {
  282. display: block;
  283. content: '';
  284. position: absolute;
  285. bottom: 0;
  286. width: 100%;
  287. height: 4rpx;
  288. background: #FA6138;
  289. border-radius: 2rpx;
  290. z-index: 1;
  291. }
  292. }
  293. }
  294. .popup {
  295. width: 100%;
  296. height: 80rpx;
  297. display: flex;
  298. align-items: center;
  299. padding: 0 30rpx;
  300. .item {
  301. display: flex;
  302. align-items: center;
  303. margin-right: 70rpx;
  304. font-size: 28rpx;
  305. font-family: PingFang SC, PingFang SC-Bold;
  306. font-weight: 700;
  307. color: #1a1a1a;
  308. ;
  309. .icon {
  310. font-size: 24rpx;
  311. margin-left: 8rpx;
  312. color: #333333;
  313. }
  314. }
  315. }
  316. }
  317. .main {
  318. padding-top: 20rpx;
  319. padding-bottom: 200rpx;
  320. }
  321. .goodsitem {
  322. height: 383rpx;
  323. margin: 0 30rpx 30rpx;
  324. padding: 0 30rpx;
  325. background: #ffffff;
  326. border-radius: 20rpx;
  327. box-shadow: 0 0 30rpx rgba(0, 0, 0, .1);
  328. .goods-title {
  329. display: flex;
  330. align-items: center;
  331. justify-content: space-between;
  332. height: 92rpx;
  333. border-bottom: 1rpx solid #ededed;
  334. font-size: 30rpx;
  335. font-family: PingFang SC, PingFang SC-Regular;
  336. font-weight: 400;
  337. text-align: left;
  338. color: #1a1a1a;
  339. .goods-name {
  340. flex: 1;
  341. width: 0;
  342. overflow: hidden;
  343. text-overflow: ellipsis;
  344. white-space: nowrap;
  345. }
  346. .time {
  347. font-size: 24rpx;
  348. color: #808080;
  349. flex-shrink: 0;
  350. }
  351. }
  352. /deep/ .goods {
  353. border: none;
  354. padding: 30rpx 0;
  355. margin-bottom: 0;
  356. }
  357. .goods-tools {
  358. display: flex;
  359. justify-content: flex-end;
  360. .btn {
  361. display: flex;
  362. align-items: center;
  363. justify-content: center;
  364. width: 150rpx;
  365. height: 70rpx;
  366. color: #fff;
  367. text-align: center;
  368. background: #ff6600;
  369. border-radius: 35rpx;
  370. }
  371. .edit {
  372. margin-left: 20rpx;
  373. background: #FA6138;
  374. }
  375. .del {
  376. margin-left: 20rpx;
  377. background: #DB1313;
  378. }
  379. }
  380. }
  381. .footer {
  382. width: 100%;
  383. padding: 30rpx 60rpx;
  384. position: fixed;
  385. bottom: 0;
  386. display: flex;
  387. align-items: center;
  388. justify-content: space-between;
  389. background-color: #fff;
  390. z-index: 9;
  391. .btn {
  392. width: 298rpx;
  393. color: #fff;
  394. text-align: center;
  395. line-height: 85rpx;
  396. border: 1rpx solid #3775F6;
  397. border-radius: 44rpx;
  398. background-color: #FA6138;
  399. font-size: 28rpx;
  400. font-family: PingFang SC, PingFang SC-Regular;
  401. font-weight: 400;
  402. text-align: center;
  403. }
  404. .online-btn {
  405. color: #FA6138;
  406. border: 1rpx solid #3775F6;
  407. background-color: #e7eefc;
  408. }
  409. }
  410. }
  411. </style>