goods.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  1. <!-- shop -->
  2. <template>
  3. <view class="shop">
  4. <view class="header-warp">
  5. <view class="header-search">
  6. <view class="search">
  7. <input
  8. type="text"
  9. placeholder-style="color:#a3a8a8;font-size:10px;"
  10. placeholder="请输入商品名称"
  11. class="cellphone"
  12. v-model="params.name"
  13. />
  14. <text class="txt" @tap="searchByname">搜索</text>
  15. </view>
  16. <view class="btn-time">
  17. <image
  18. src="../../static/images/addicon.png"
  19. class="timeicon"
  20. @tap="topage()"
  21. ></image>
  22. </view>
  23. </view>
  24. <view class="uni-list-cell">
  25. <view class="uni-list-cell-db">
  26. <picker
  27. @change="bindPickerChange"
  28. :value="index"
  29. :range="shopArray"
  30. range-key="name"
  31. class="uni-upd"
  32. >
  33. <view class="uni-input">{{ shopArray[index].name }}</view>
  34. </picker>
  35. <view class="icon-warp">
  36. <image
  37. src="../../static/images/moreicon.png"
  38. class="iconRight"
  39. ></image>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="header-bar">
  44. <view
  45. class="item"
  46. @tap="changeTabByStatus(1, '1')"
  47. :class="{ active: isactive === 1 }"
  48. >
  49. <view class="ordertype">待审核</view>
  50. <view class="heng"></view>
  51. </view>
  52. <view
  53. class="item"
  54. @tap="changeTab(2, '1')"
  55. :class="{ active: isactive === 2 }"
  56. >
  57. <view class="ordertype">已上架</view>
  58. <view class="heng"></view>
  59. </view>
  60. <view
  61. class="item"
  62. @tap="changeTab(3, '0')"
  63. :class="{ active: isactive === 3 }"
  64. >
  65. <view class="ordertype">已下架</view>
  66. <view class="heng"></view>
  67. </view>
  68. <view class="line"></view>
  69. </view>
  70. </view>
  71. <view style="height: 272upx;"></view>
  72. <!-- 审核 -->
  73. <view class="order-content" v-if="isactive === 1">
  74. <view class="order-list" v-for="(item, index) in shoplist" :key="index">
  75. <view class="order-title">
  76. <text class="ordernum">{{ item.name }}</text>
  77. </view>
  78. <view class="order-detail">
  79. <view class="left">
  80. <image :src="item.icon" class="img"></image>
  81. </view>
  82. <view class="center">
  83. <view class="shop-detail door">所属店铺:{{ item.shopName }}</view>
  84. <view class="shop-detail type">类型:{{ item.typeName }}</view>
  85. <view class="shop-detail putaway"
  86. >上下架状态:{{ item.upDown | putaway }}</view
  87. >
  88. <view class="shop-detail status"
  89. >状态:{{ item.status | state }}</view
  90. >
  91. </view>
  92. <view class="right" v-if="item.price">¥<text class="price">{{ item.price | dounit }}</text></view>
  93. </view>
  94. <view class="operate">
  95. <view
  96. class="btn stick"
  97. :class="{ isactive: item.sort != 0 }"
  98. @tap="sticktop(item.id, item.sort)"
  99. >{{ item.sort === 0 ? '置顶' : '取消置顶' }}</view
  100. >
  101. <!-- <view class="btn sold" @tap="passGet(item.id)">审核</view> -->
  102. <view class="btn compile" @tap="topage(item.id)">编辑</view>
  103. <view class="btn delete" @tap="deleteshop(item.id)">删除</view>
  104. </view>
  105. </view>
  106. </view>
  107. <!-- 已上架 -->
  108. <view class="order-content" v-if="isactive === 2">
  109. <view class="order-list" v-for="(item, index) in shoplist" :key="index">
  110. <view class="order-title">
  111. <text class="ordernum">{{ item.name }}</text>
  112. </view>
  113. <view class="order-detail">
  114. <view class="left">
  115. <image :src="item.icon" class="img"></image>
  116. </view>
  117. <view class="center">
  118. <view class="shop-detail door">所属店铺:{{ item.shopName }}</view>
  119. <view class="shop-detail type">类型:{{ item.typeName }}</view>
  120. <view class="shop-detail putaway"
  121. >上下架状态:{{ item.upDown | putaway }}</view
  122. >
  123. <view class="shop-detail status"
  124. >状态:{{ item.status | state }}</view
  125. >
  126. </view>
  127. <view class="right" v-if="item.price">¥<text class="price">{{ item.price | dounit }}</text></view>
  128. </view>
  129. <view class="operate">
  130. <view
  131. class="btn stick"
  132. :class="{ isactive: item.sort != 0 }"
  133. @tap="sticktop(item.id, item.sort)"
  134. >{{ item.sort === 0 ? '置顶' : '取消置顶' }}</view
  135. >
  136. <view class="btn sold" @tap="shopPutDown(item.id)">下架</view>
  137. <view class="btn compile" @tap="topage(item.id)">编辑</view>
  138. <view class="btn delete" @tap="deleteshop(item.id)">删除</view>
  139. </view>
  140. </view>
  141. </view>
  142. <!-- 已下架 -->
  143. <view class="order-content" v-if="isactive === 3">
  144. <view class="order-list" v-for="(item, index) in shoplist" :key="index">
  145. <view class="order-title">
  146. <text class="ordernum">{{ item.name }}</text>
  147. </view>
  148. <view class="order-detail">
  149. <view class="left">
  150. <image :src="item.icon" class="img"></image>
  151. </view>
  152. <view class="center">
  153. <view class="shop-detail door">所属店铺:{{ item.shopName }}</view>
  154. <view class="shop-detail type">类型:{{ item.typeName }}</view>
  155. <view class="shop-detail putaway"
  156. >上下架状态:{{ item.upDown | putaway }}</view
  157. >
  158. <view class="shop-detail status"
  159. >状态:{{ item.status | state }}</view
  160. >
  161. </view>
  162. <view class="right" v-if="item.price"
  163. >¥<text class="price">{{ item.price | dounit }}</text></view
  164. >
  165. </view>
  166. <view class="operate">
  167. <view
  168. class="btn stick"
  169. :class="{ isactive: item.sort != 0 }"
  170. @tap="sticktop(item.id, item.sort)"
  171. >{{ item.sort === 0 ? '置顶' : '取消置顶' }}</view
  172. >
  173. <view class="btn sold" @tap="shopPutUp(item.id)">上架</view>
  174. <view class="btn compile" @tap="topage(item.id)">编辑</view>
  175. <view class="btn delete" @tap="deleteshop(item.id)">删除</view>
  176. </view>
  177. </view>
  178. </view>
  179. <tabBar :currentIndex="typeNum" :role="roleList"></tabBar>
  180. <uni-load-more :status="more"> </uni-load-more>
  181. <rf-loading v-if="loading"></rf-loading>
  182. </view>
  183. </template>
  184. <script>
  185. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  186. export default {
  187. name: 'order',
  188. components: { uniLoadMore },
  189. data() {
  190. //这里存放数据
  191. return {
  192. typeNum: 2,
  193. roleList:[],
  194. deleteId: '',
  195. scenicID: 0, // 景区id 唯一(一个账号代表一个景区)
  196. loading: false,
  197. more: 'loading', // more loading noMore
  198. shopArray: [{ name: '全部', id: '' }],
  199. shopID: '',
  200. index: 0,
  201. topstatus: '-1', // 置顶传-1,取消置顶传-2
  202. isactive: 1,
  203. soleStatus: 1, // 触底状态
  204. shoplist: [],
  205. // 列表参数
  206. putAwat: '1', // 已上架1;已下架0
  207. status: '1', // 待审核:1,审核通过:2,审核未通过:3
  208. params: {
  209. pageNum: 1,
  210. pageSize: 10,
  211. mid: 0, // 景区id
  212. status: '1', // 审核状态
  213. upDown: '', // 上下架状态
  214. shopId: '', // 商铺id 选择框
  215. name: '',
  216. },
  217. };
  218. },
  219. filters: {
  220. putaway(val) {
  221. if (val === '0') {
  222. return '已下架';
  223. } else if (val === '1') {
  224. return '已上架';
  225. }
  226. },
  227. state(val) {
  228. if (val === '1') {
  229. return '待审核';
  230. } else if (val === '2') {
  231. return '审核通过';
  232. } else if (val === '3') {
  233. return '审核未通过';
  234. }
  235. },
  236. dounit(val) {
  237. if (val) {
  238. return val / 100;
  239. } else {
  240. return '';
  241. }
  242. },
  243. },
  244. onReady () {
  245. // this.roleList = this.$mStore.getters.hasrole.reverse()
  246. let role = uni.getStorageSync('role')
  247. this.roleList = role.reverse()
  248. },
  249. // 下拉刷新
  250. onPullDownRefresh() {
  251. this.more = 'loading';
  252. this.isactive = 1;
  253. this.params = {
  254. pageNum: 1,
  255. pageSize: 10,
  256. mid: 0, // 景区id
  257. status: '1', // 审核状态
  258. upDown: '', // 上下架状态
  259. shopId: '', // 商铺id 选择框
  260. name: '',
  261. };
  262. this.getShopMessage();
  263. },
  264. // 上拉加载
  265. onReachBottom() {
  266. if (this.soleStatus === 1) {
  267. if (this.more === 'noMore') {
  268. return;
  269. }
  270. this.getMoreByStatus();
  271. }
  272. },
  273. onShow() {
  274. this.getShopList();
  275. this.getShopMessage();
  276. },
  277. //方法集合
  278. methods: {
  279. // 跳转详情
  280. topage(id) {
  281. // if (id) {
  282. // uni.setStorageSync('Id', id);
  283. // }
  284. this.$mRouter.push({ route: '/pages/goods/shopdetail', query:{id: id}});
  285. },
  286. // 删除商品
  287. async deleteshop(id) {
  288. let _self = this;
  289. this.deleteId = id;
  290. uni.showModal({
  291. content: '是否删除该商品?',
  292. success: (confirmRes) => {
  293. if (confirmRes.confirm) {
  294. _self.$http
  295. .delete('/goods/del/' + this.deleteId)
  296. .then(async (res) => {
  297. if (res.code === 200 && res.msg === 'OK') {
  298. _self.$mHelper.toast('删除成功');
  299. setTimeout(() => {
  300. _self.getTicketShopList();
  301. }, 500);
  302. }
  303. });
  304. }
  305. },
  306. });
  307. },
  308. // 根据名字搜索
  309. searchByname() {
  310. this.more = 'loading';
  311. this.params.pageNum = 1;
  312. this.getTicketShopList();
  313. },
  314. // 选择商铺
  315. bindPickerChange(e) {
  316. this.more = 'loading';
  317. this.params.pageNum = 1;
  318. this.shopID = '';
  319. this.index = e.detail.value;
  320. this.params.shopId = this.shopArray[this.index].id;
  321. this.getTicketShopList();
  322. },
  323. // 获取店铺列表
  324. async getShopList() {
  325. await this.$http.get('/homePage/getShopByMerId').then((res) => {
  326. if (res.data && res.code === 200) {
  327. let newarr = [{ name: '全部', id: '' }];
  328. this.shopArray = newarr.concat(res.data);
  329. }
  330. });
  331. },
  332. // 商家信息
  333. async getShopMessage() {
  334. await this.$http.get('/getUserInfo').then(async (res) => {
  335. if (res.data) {
  336. uni.setStorageSync('scenicId', res.data.id);
  337. this.params.mid = res.data.id;
  338. this.getTicketShopList();
  339. }
  340. });
  341. uni.stopPullDownRefresh(); // 关闭下拉刷新
  342. },
  343. // 待审核tab切换
  344. changeTabByStatus(type, status) {
  345. this.more = 'loading';
  346. this.shoplist = [];
  347. this.params.pageNum = 1;
  348. this.isactive = type;
  349. this.params.status = status;
  350. this.status = status;
  351. delete this.params.upDown;
  352. this.getTicketShopList();
  353. },
  354. // tab
  355. changeTab(type, putaway) {
  356. this.more = 'loading';
  357. this.params.pageNum = 1;
  358. this.isactive = type;
  359. this.params.upDown = putaway;
  360. this.putAwat = putaway;
  361. delete this.params.status;
  362. this.getTicketShopList();
  363. },
  364. // 置顶
  365. sticktop(id, status) {
  366. if (status != 0) {
  367. this.topstatus = '-2';
  368. } else {
  369. this.topstatus = '-1';
  370. }
  371. this.$http
  372. .PUT('/goods/changeSort?id=' + id + '&sort=' + this.topstatus)
  373. .then((res) => {
  374. if (res.code === 200) {
  375. if (status != 0) {
  376. this.$mHelper.toast('取消成功');
  377. } else {
  378. this.$mHelper.toast('置顶成功');
  379. }
  380. this.getTicketShopList();
  381. }
  382. });
  383. },
  384. // 商品列表(待审核状态)
  385. async getTicketShopList() {
  386. this.soleStatus = 1;
  387. this.shoplist = [];
  388. // 判断tab切换的条件
  389. if (this.params.upDown === '1' || this.params.upDown === '0') {
  390. delete this.params.status;
  391. } else {
  392. delete this.params.upDown;
  393. }
  394. await this.$http.get('/goods/list', this.params).then((res) => {
  395. if (res.data.list.length > 0) {
  396. this.shoplist = res.data.list;
  397. if (res.data.nextPage === 0) {
  398. this.more = 'noMore';
  399. }
  400. } else {
  401. this.more = 'noMore';
  402. }
  403. });
  404. },
  405. // 更多(待审核状态)
  406. async getMoreByStatus() {
  407. this.params.pageNum++;
  408. let listArr = [];
  409. // 判断tab切换的条件
  410. if (this.params.upDown === '1' || this.params.upDown === '0') {
  411. delete this.params.status;
  412. } else {
  413. delete this.params.upDown;
  414. }
  415. await this.$http.get('/goods/list', this.params).then((res) => {
  416. if (res.data.list.length > 0) {
  417. listArr = res.data.list;
  418. this.shoplist = this.shoplist.concat(listArr);
  419. if (res.data.nextPage === 0) {
  420. this.more = 'noMore';
  421. }
  422. } else {
  423. this.more = 'noMore';
  424. return;
  425. }
  426. });
  427. },
  428. // 通过审核
  429. passGet(id) {},
  430. // 下架
  431. shopPutDown(id) {
  432. this.changeShopStatus(id, this.params.upDown);
  433. },
  434. // 上架
  435. shopPutUp(id) {
  436. this.changeShopStatus(id, this.params.upDown);
  437. },
  438. // 修改商品状态
  439. async changeShopStatus(ids, upordown, state) {
  440. let upstate = 0;
  441. if (upordown === '1') {
  442. upstate = 0;
  443. } else {
  444. upstate = 1;
  445. }
  446. let data = {
  447. id: ids,
  448. upDown: upstate,
  449. status: state,
  450. };
  451. if (state) {
  452. delete data.upDown;
  453. } else {
  454. delete data.status;
  455. }
  456. await this.$http
  457. .postBody('/goods/changeStatusOrUpDown', data)
  458. .then(async (res) => {
  459. if (res.code === 200 && res.msg === 'OK') {
  460. this.getTicketShopList();
  461. this.$mHelper.toast('操作成功');
  462. }
  463. });
  464. },
  465. },
  466. };
  467. </script>
  468. <style lang="scss" scoped>
  469. .shop {
  470. background-color: #f4f4f4;
  471. .header-warp {
  472. width: 100%;
  473. background-color: #fff;
  474. padding: 15upx 33upx 0;
  475. position: fixed;
  476. z-index: 99;
  477. .header-search {
  478. display: flex;
  479. align-items: center;
  480. .search {
  481. flex: 1;
  482. display: flex;
  483. align-items: center;
  484. height: 80upx;
  485. margin-left: 20upx;
  486. background-color: #f7f7f7;
  487. border-radius: 10upx;
  488. .cellphone {
  489. flex: 1;
  490. height: 100%;
  491. color: $titleColor;
  492. padding-left: 20upx;
  493. }
  494. .search-holder {
  495. color: #f00;
  496. }
  497. .txt {
  498. height: 72upx;
  499. width: 90upx;
  500. text-align: center;
  501. line-height: 72upx;
  502. color: #a95cff;
  503. font-size: 28upx;
  504. }
  505. }
  506. .btn-time {
  507. margin-left: 20upx;
  508. display: flex;
  509. justify-content: center;
  510. align-items: center;
  511. .timeicon {
  512. width: 48upx;
  513. height: 48upx;
  514. }
  515. }
  516. }
  517. .uni-list-cell {
  518. padding: 0 20upx;
  519. border-bottom: 1px solid #f4f4f4;
  520. .uni-list-cell-db {
  521. height: 80upx;
  522. font-size: 28upx;
  523. display: flex;
  524. justify-content: space-between;
  525. align-items: center;
  526. background-color: #fff;
  527. color: #8f8f8f;
  528. font-size: 30upx;
  529. .uni-upd {
  530. width: 100%;
  531. }
  532. }
  533. .uni-input {
  534. height: 100%;
  535. line-height: 80upx;
  536. }
  537. .icon-warp {
  538. width: 19upx;
  539. .iconRight {
  540. width: 19upx;
  541. height: 27upx;
  542. }
  543. }
  544. }
  545. .header-bar {
  546. display: flex;
  547. justify-content: center;
  548. align-items: center;
  549. position: relative;
  550. .item {
  551. position: relative;
  552. width: 33.33%;
  553. height: 99upx;
  554. display: flex;
  555. justify-content: center;
  556. align-items: center;
  557. flex-direction: column;
  558. .ordertype {
  559. position: relative;
  560. font-size: 30upx;
  561. letter-spacing: 3upx;
  562. color: #7a7c7c;
  563. }
  564. .heng {
  565. position: absolute;
  566. display: none;
  567. bottom: 0;
  568. width: 40upx;
  569. height: 6upx;
  570. border-radius: 4upx;
  571. background-color: #a95cff;
  572. }
  573. }
  574. .active .ordertype {
  575. color: #a95cff;
  576. }
  577. .active .heng {
  578. display: block;
  579. }
  580. }
  581. }
  582. .order-content {
  583. padding: 24upx 32upx 0;
  584. .order-list {
  585. background-color: #fff;
  586. border-radius: 10upx;
  587. padding: 30upx 24upx 33upx;
  588. margin-bottom: 24upx;
  589. .order-title {
  590. border-bottom: 1px solid $bordrColor;
  591. display: flex;
  592. justify-content: space-between;
  593. align-items: center;
  594. padding-bottom: 22upx;
  595. .ordernum {
  596. font-size: 34upx;
  597. color: $titleColor;
  598. }
  599. }
  600. .order-detail {
  601. margin-top: 24upx;
  602. display: flex;
  603. .left {
  604. .img {
  605. width: 120upx;
  606. height: 120upx;
  607. border-radius: 5upx;
  608. background-color: pink;
  609. }
  610. }
  611. .center {
  612. width: 370upx;
  613. margin-left: 25upx;
  614. .shop-detail {
  615. font-size: 26upx;
  616. color: #7a7a7a;
  617. margin-top: 7upx;
  618. &:first-child {
  619. margin-top: 0;
  620. }
  621. }
  622. }
  623. .right {
  624. flex: 1;
  625. color: #ff6a5e;
  626. .price {
  627. font-size: 30upx;
  628. }
  629. }
  630. }
  631. .operate {
  632. border-top: 1px solid #e7e7e7;
  633. padding-top: 24upx;
  634. display: flex;
  635. justify-content: center;
  636. align-items: center;
  637. margin-top: 10upx;
  638. .btn {
  639. width: 160upx;
  640. height: 58upx;
  641. border: 1upx solid #7a7c7c;
  642. border-radius: 6upx;
  643. margin-right: 22upx;
  644. text-align: center;
  645. line-height: 58upx;
  646. font-size: 28upx;
  647. color: #7a7c7c;
  648. letter-spacing: 3upx;
  649. }
  650. .isactive {
  651. color: #ff6a5e;
  652. border: 1upx solid #ff6a5e;
  653. }
  654. .delete {
  655. margin-right: 0;
  656. background-color: #ff6a5e;
  657. color: #ffffff;
  658. border: none;
  659. }
  660. }
  661. }
  662. }
  663. }
  664. </style>