index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. <template>
  2. <view class="product">
  3. <view class="head">
  4. <view class="handle">
  5. <view class="head_left">
  6. <span class="cuIcon-back" @click="back"></span>
  7. </view>
  8. <span class="center">商品管理</span>
  9. <view class="head_right">
  10. <span class="cuIcon-search" @click="goSearch"></span>
  11. <view class="manage" @click="manage">
  12. {{isManage?'退出管理':'管理'}}
  13. </view>
  14. </view>
  15. </view>
  16. <view class="type">
  17. <view class="type_item" :class="currentIndex == index?'active':''" v-for="(item,index) in typeList" :key="index"
  18. @click="selectType(item,index)">
  19. {{item.type}}({{item.num}})
  20. <span class="line" v-if="currentIndex == index"></span>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="list">
  25. <view class="product_item" v-for="(item,index) in productList" :key="index" @click="goDetails(item)">
  26. <view class="status">
  27. <span class="round" v-if="item.productStatus =='1'">售卖中</span>
  28. <span class="round no" v-if="item.productStatus =='0'" style="color:#666666 ;">未上架</span>
  29. <span class="line"></span>
  30. <span v-if="item.saleStartDate">{{item.saleStartDate.slice(0,10)}}-{{item.saleEndDate.slice(0,10)}}</span>
  31. <!-- <span>已售:{{item.num}}</span>
  32. <span>库存:{{item.inventory}}</span> -->
  33. </view>
  34. <view class="details">
  35. <view class="img">
  36. <image :src="item.url" mode=""></image>
  37. </view>
  38. <view class="data">
  39. <span>{{item.productName}}</span>
  40. <!-- <span>售卖时间:{{item.time}}</span> -->
  41. <view class="repertory">库存:不限 <span></span> 销量:{{item.soldQuantity}}</view>
  42. <view class="price">
  43. <span style="font-size: 22rpx;margin: 0px;">¥</span>{{item.soldPrice}}
  44. <span style="color:#999 ;font-size: 22rpx; text-decoration: line-through;">¥{{item.price}}</span>
  45. </view>
  46. </view>
  47. <view class="tag" v-if="isManage" @click.stop="select(item)">
  48. <!-- <span>组合套餐</span> -->
  49. <!-- <span class="frame"></span> -->
  50. <image src="/static/product/select.png" mode="" v-if="item.select"></image>
  51. <image src="/static/product/round.png" mode="" v-else></image>
  52. </view>
  53. </view>
  54. <view class="btn_box">
  55. <view class="delist">
  56. 下架
  57. </view>
  58. <view class="edit delist">
  59. 编辑
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. <view class="creat">
  65. <view class="operate" v-if="isManage">
  66. <view class="all" @click="allSelect">
  67. <image src="/static/product/select.png" mode="" v-if="isAll"></image>
  68. <image src="/static/product/round.png" mode="" v-else></image>
  69. 全选
  70. </view>
  71. <view class="delete">删除</view>
  72. <view class="delete delist">下架</view>
  73. </view>
  74. <view class="btn" @click="creatProduct" v-else>
  75. <image src="/static/product/product.png" mode=""></image>
  76. 创建商品
  77. </view>
  78. </view>
  79. <view class="popup" v-if="isDelete">
  80. <view class="content">
  81. <view class="title">
  82. <span>删除商品</span>
  83. </view>
  84. <view class="center">
  85. <image src="/static/index/close.png" mode="" v-if="canBeDelete"></image>
  86. <image src="/static/product/error.png" mode="" v-else></image>
  87. <view class="error" v-if="canBeDelete">
  88. 确定要删除?
  89. </view>
  90. <view class="error" v-else>
  91. 当前门店还存在有效服务券<br />
  92. <span style="margin-top: 12rpx;">暂时无法关闭门店</span>
  93. </view>
  94. </view>
  95. <view class="sub" @click="isSuccess = false">
  96. <view class="button">
  97. 确定
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. </view>
  103. </template>
  104. <script>
  105. export default {
  106. data() {
  107. return {
  108. isManage: false,
  109. currentIndex: 0,
  110. productStatus:0,//商品状态,默认1售卖中,0未上架,2审核中,3未通过
  111. isAll: false,
  112. isDelete: false,
  113. canBeDelete: true,
  114. typeList: [{
  115. type: '售卖中',
  116. num: 21
  117. },
  118. {
  119. type: '待上架',
  120. num: 8
  121. },
  122. {
  123. type: '审核中',
  124. num: 0
  125. },
  126. {
  127. type: '未通过',
  128. num: 6
  129. }
  130. ],
  131. productList: []
  132. }
  133. },
  134. methods: {
  135. //返回
  136. back() {
  137. uni.navigateBack({
  138. delta: 1
  139. });
  140. },
  141. //切换分类
  142. selectType(item, index) {
  143. this.currentIndex = index
  144. },
  145. //是否管理商品
  146. manage() {
  147. this.isManage = !this.isManage
  148. },
  149. // 跳转至搜索页面
  150. goSearch() {
  151. uni.navigateTo({
  152. url: '/pages/product/search'
  153. })
  154. },
  155. //跳转至详情
  156. goDetails(item) {
  157. uni.navigateTo({
  158. url: '/pages/product/details'
  159. })
  160. },
  161. //跳转至创建商品
  162. creatProduct() {
  163. uni.navigateTo({
  164. url: '/pages/product/creatProduct'
  165. })
  166. },
  167. select(item) {
  168. item.select = !item.select
  169. },
  170. allSelect() {
  171. if (this.isAll) {
  172. this.isAll = false
  173. this.productList.forEach(item => {
  174. item.select = false
  175. })
  176. } else {
  177. this.isAll = true
  178. this.productList.forEach(item => {
  179. item.select = true
  180. })
  181. }
  182. },
  183. getProductList() {
  184. this.$http.get("/app/product/list?merchantId=" + '111' + "&productStatus=" + this.productStatus, ).then(res => {
  185. if (res.data.code == 200) {
  186. res.data.result.records.forEach((item) => {
  187. item.select = false;
  188. })
  189. this.productList = res.data.result.records
  190. console.log(this.productList)
  191. }
  192. })
  193. }
  194. },
  195. mounted() {
  196. this.getProductList()
  197. }
  198. }
  199. </script>
  200. <style lang="scss" scoped>
  201. .product {
  202. width: 100%;
  203. height: 100vh;
  204. display: flex;
  205. flex-direction: column;
  206. justify-content: space-between;
  207. background: #F7F8FC;
  208. .head {
  209. width: 100%;
  210. background: linear-gradient(87deg, #FFFFFF 0%, #A3CDFF 100%), linear-gradient(360deg, #FFFFFF 0%, rgba(255, 255, 255, 0) 100%);
  211. .handle {
  212. height: 112rpx;
  213. display: flex;
  214. justify-content: space-between;
  215. align-items: center;
  216. padding: 0px 24rpx;
  217. position: relative;
  218. .head_left {
  219. font-size: 40rpx;
  220. }
  221. .center {
  222. position: absolute;
  223. left: 50%;
  224. top: 50%;
  225. transform: translate(-50%, -50%);
  226. font-size: 36rpx;
  227. font-weight: 600;
  228. }
  229. .head_right {
  230. display: flex;
  231. justify-content: space-between;
  232. align-items: center;
  233. span {
  234. width: 40rpx;
  235. height: 40rpx;
  236. display: flex;
  237. justify-content: center;
  238. align-items: center;
  239. }
  240. .manage {
  241. // width: 150rpx;
  242. margin-left: 28rpx;
  243. }
  244. }
  245. }
  246. .type {
  247. display: flex;
  248. background-color: #fff;
  249. .type_item {
  250. width: 25%;
  251. height: 75rpx;
  252. display: flex;
  253. justify-content: center;
  254. align-items: center;
  255. font-size: 26rpx;
  256. color: #888888;
  257. position: relative;
  258. .line {
  259. position: absolute;
  260. bottom: 10rpx;
  261. width: 53rpx;
  262. height: 8rpx;
  263. background: #449AFF;
  264. border-radius: 7rpx;
  265. }
  266. }
  267. .active {
  268. color: #333;
  269. }
  270. }
  271. }
  272. .list {
  273. width: 100%;
  274. flex: 1;
  275. // padding: 0px 20rpx;
  276. overflow-y: auto;
  277. .product_item {
  278. width: 100%;
  279. background-color: #fff;
  280. border-radius: 20rpx;
  281. padding: 20rpx 40rpx;
  282. margin-top: 20rpx;
  283. .status {
  284. display: flex;
  285. align-items: center;
  286. .round {
  287. display: flex;
  288. align-items: center;
  289. color: #49A03F;
  290. }
  291. .round::before {
  292. content: "";
  293. display: inline-block;
  294. width: 9rpx;
  295. height: 9rpx;
  296. background: #49A03F;
  297. border-radius: 50%;
  298. margin-right: 8rpx;
  299. }
  300. .no {
  301. color: #666666;
  302. }
  303. .no::before {
  304. content: "";
  305. display: inline-block;
  306. width: 9rpx;
  307. height: 9rpx;
  308. background: #666666;
  309. border-radius: 50%;
  310. margin-right: 8rpx;
  311. }
  312. .line {
  313. display: block;
  314. width: 1rpx;
  315. height: 20rpx;
  316. background: #d9d9d9;
  317. margin: 0 12rpx;
  318. }
  319. }
  320. .details {
  321. width: 100%;
  322. height: auto;
  323. min-height: 132rpx;
  324. height: 132rpx;
  325. display: flex;
  326. align-items: center;
  327. margin-top: 20rpx;
  328. .img {
  329. margin-right: 16rpx;
  330. image {
  331. width: 132rpx;
  332. height: 132rpx;
  333. }
  334. }
  335. .data {
  336. flex: 1;
  337. height: 100%;
  338. display: flex;
  339. flex-direction: column;
  340. justify-content: space-between;
  341. font-weight: 600;
  342. font-style: 28rpx;
  343. .repertory {
  344. font-size: 24rpx;
  345. display: flex;
  346. align-items: center;
  347. color: #666;
  348. font-weight: 400;
  349. span {
  350. display: block;
  351. width: 1rpx;
  352. height: 20rpx;
  353. background: #d9d9d9;
  354. margin: 0 12rpx;
  355. }
  356. }
  357. .price {
  358. display: flex;
  359. align-items: center;
  360. font-size: 30rpx;
  361. font-weight: 600;
  362. span {
  363. font-size: 26rpx;
  364. margin-left: 20rpx;
  365. font-weight: 400;
  366. }
  367. }
  368. }
  369. .tag {
  370. width: 40rpx;
  371. height: 40rpx;
  372. display: flex;
  373. flex-direction: column;
  374. align-items: center;
  375. image {
  376. width: 40rpx;
  377. height: 40rpx;
  378. }
  379. }
  380. }
  381. .btn_box {
  382. width: 100%;
  383. display: flex;
  384. justify-content: end;
  385. align-items: center;
  386. margin-top: 20rpx;
  387. .delist {
  388. width: 100rpx;
  389. height: 50rpx;
  390. border-radius: 8rpx;
  391. border: 1px solid #CCCCCC;
  392. display: flex;
  393. justify-content: center;
  394. align-items: center;
  395. font-size: 26rpx;
  396. color: #666666;
  397. }
  398. .edit {
  399. margin-left: 20rpx;
  400. background: rgba(68, 154, 255, 0.05);
  401. border: 1px solid #449AFF;
  402. color: #449AFF;
  403. }
  404. }
  405. }
  406. }
  407. .creat {
  408. width: 100%;
  409. height: 100rpx;
  410. background-color: #fff;
  411. display: flex;
  412. justify-content: center;
  413. align-items: center;
  414. .btn {
  415. width: 672rpx;
  416. height: 76rpx;
  417. display: flex;
  418. justify-content: center;
  419. align-items: center;
  420. background: linear-gradient(90deg, #77B6FF 0%, #449AFF 100%);
  421. border-radius: 75rpx;
  422. font-size: 28rpx;
  423. color: #FFFFFF;
  424. image {
  425. width: 40rpx;
  426. height: 40rpx;
  427. margin-right: 10rpx;
  428. }
  429. }
  430. .operate {
  431. width: 100%;
  432. display: flex;
  433. // justify-content: space-between;
  434. align-items: center;
  435. padding: 0px 20rpx;
  436. .delete {
  437. width: 205rpx;
  438. height: 76rpx;
  439. background: linear-gradient(90deg, #77B6FF 0%, #449AFF 100%);
  440. border-radius: 49rpx;
  441. font-size: 28rpx;
  442. color: #FFFFFF;
  443. display: flex;
  444. justify-content: center;
  445. align-items: center;
  446. margin-right: 24rpx;
  447. margin-left: 140rpx;
  448. }
  449. .delist {
  450. margin-left: 0rpx;
  451. background: linear-gradient(90deg, #FFA05B 0%, #FF7918 100%);
  452. }
  453. .all {
  454. width: 25%;
  455. // height: 60rpx;
  456. // border: 1px solid #999;
  457. display: flex;
  458. justify-content: center;
  459. align-items: center;
  460. image {
  461. width: 40rpx;
  462. height: 40rpx;
  463. margin-right: 10rpx;
  464. }
  465. }
  466. }
  467. }
  468. .popup {
  469. width: 100vw;
  470. height: 100vh;
  471. position: fixed;
  472. top: 0;
  473. left: 0;
  474. background: rgba(0, 0, 0, 0.4);
  475. display: flex;
  476. align-items: center;
  477. justify-content: center;
  478. .content {
  479. width: 570rpx;
  480. background: #FFFFFF;
  481. border-radius: 16rpx;
  482. padding: 0px 24rpx;
  483. padding-bottom: 16rpx;
  484. .title {
  485. width: 100%;
  486. height: 86rpx;
  487. font-size: 32rpx;
  488. color: #333333;
  489. font-weight: 600;
  490. border-bottom: 1px solid #EEEEEE;
  491. display: flex;
  492. align-items: center;
  493. justify-content: center;
  494. }
  495. .center {
  496. font-size: 30rpx;
  497. color: #333333;
  498. line-height: 35rpx;
  499. display: flex;
  500. flex-direction: column;
  501. align-items: center;
  502. justify-content: center;
  503. padding-top: 28rpx;
  504. border-bottom: 1px solid #EEEEEE;
  505. padding-bottom: 40rpx;
  506. margin-bottom: 16rpx;
  507. .error {
  508. text-align: center;
  509. }
  510. image {
  511. width: 100rpx;
  512. height: 100rpx;
  513. margin-bottom: 10rpx;
  514. }
  515. }
  516. .sub {
  517. width: 320rpx;
  518. height: 68rpx;
  519. border-radius: 66rpx;
  520. font-size: 28rpx;
  521. color: #FFFFFF;
  522. display: flex;
  523. align-items: center;
  524. justify-content: center;
  525. margin: 0rpx auto;
  526. .button {
  527. width: 320rpx;
  528. height: 68rpx;
  529. background: #449AFF;
  530. border-radius: 66rpx;
  531. display: flex;
  532. align-items: center;
  533. justify-content: center;
  534. }
  535. }
  536. .start {
  537. background: #53CC48;
  538. }
  539. .rest {
  540. background: #FF8024;
  541. }
  542. }
  543. }
  544. }
  545. </style>