index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. <template>
  2. <view class="footprint-box-container">
  3. <JHeader title="浏览足迹" width="50" height="50" style="padding: 24upx 0 0;"></JHeader>
  4. <view v-if="footprintList && footprintList.length">
  5. <view class="wid function-box">
  6. <view v-if="allCheckShow" class="finishbox" @click="allCheckShow = false">完成</view>
  7. <view v-else class="flex-row-plus editicon-box flex-items fs28" @click="editClick">
  8. <tui-icon name="edit" :size="40" unit="upx" color="#333333"></tui-icon>
  9. <label class="mar-left-10">编辑</label>
  10. </view>
  11. </view>
  12. <view v-for="(ditem, findex) in footprintList.filter((item) => item.isReady !== 1)" :key="findex" class="swipe-box">
  13. <view class="daytime-fillet">
  14. <label class="mar-left-30">{{ ditem.createTime }}</label>
  15. </view>
  16. <tui-swipe-action
  17. v-for="(item, index) in ditem.products" :key="item.footprintId" :params="{ findex, index }"
  18. :open="item.show" :forbid="allCheckShow" :actions="options" :closable="false"
  19. class="listItem"
  20. @click="delFootProduction"
  21. >
  22. <template #content>
  23. <view class="itemBox">
  24. <view class="item wid flex-display">
  25. <view v-if="allCheckShow" class="selectIconBox">
  26. <tui-icon
  27. v-if="item.selected == 1" name="circle-fill" :size="40" unit="upx"
  28. color="#c5aa7b"
  29. margin="0 30upx 0 0" @click="footItemSel(index, findex, 0)"
  30. ></tui-icon>
  31. <tui-icon
  32. v-else name="circle" :size="40" unit="upx"
  33. color="#cccccc" margin="0 30upx 0 0"
  34. @click="footItemSel(index, findex, 1)"
  35. ></tui-icon>
  36. </view>
  37. <view
  38. class="flex-items"
  39. @click.stop="go(`/another-tf/another-serve/goodsDetails/index?shopId=${item.shopId}&productId=${item.productId}&skuId=${item.skuId}`)"
  40. >
  41. <image class="product-img default-img" mode="aspectFill" :src="common.seamingImgUrl(item.image)" />
  42. <view class="title-wrap mar-left-20">
  43. <text
  44. class="title fs28"
  45. style="overflow: hidden;word-break: break-all;text-overflow: ellipsis;display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 2;"
  46. >
  47. {{
  48. item.productName }}
  49. </text>
  50. <view class="flex-items">
  51. <ATFActivityImage :type="item.activityType"></ATFActivityImage>
  52. <label class="fs40 mar-right-20 font-color-C83732">¥{{ item.price }}</label>
  53. <label class="font-color-CCC discountsPriceLine fs24">¥{{ item.originalPrice }}</label>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </template>
  60. </tui-swipe-action>
  61. </view>
  62. <view v-show="allCheckShow" class="allcheck-box flex-row-plus flex-sp-between flex-items">
  63. <view class="left">
  64. <tui-icon
  65. v-if="isAllCheck" name="circle-fill" :size="40" unit="upx"
  66. color="#c5aa7b" margin="0 30upx 0 0"
  67. @click="allSel(0)"
  68. ></tui-icon>
  69. <tui-icon
  70. v-else name="circle" :size="40" unit="upx"
  71. color="#cccccc" margin="0 30upx 0 0"
  72. @click="allSel(1)"
  73. ></tui-icon>
  74. <text>全选</text>
  75. </view>
  76. <view class="right">
  77. <view class="btn-delete" @click="showCardModal">删除</view>
  78. </view>
  79. </view>
  80. <view v-if="allCheckShow" class="pad-bot-140"></view>
  81. </view>
  82. <view style="padding-bottom: 45upx;">
  83. <LoadingMore
  84. :status="!isEmpty && !footprintList.length
  85. ? 'loading' : !isEmpty && footprintList.length && (footprintList.length >= footprintTotal) ? 'no-more' : ''"
  86. >
  87. </LoadingMore>
  88. <tui-no-data v-if="isEmpty" :fixed="false" style="margin-top: 60upx;">暂无数据</tui-no-data>
  89. </view>
  90. <!-- 删除确认弹窗 -->
  91. <tui-modal :show="cardModal" :custom="true" :fadein="true">
  92. <view class="Put-box1">
  93. <view class="text-align fs34 fs-bold">
  94. 温馨提示
  95. </view>
  96. <view class="mar-top-40 text-align">
  97. 是否删除该浏览足迹?
  98. </view>
  99. <view class="btn submit" @click="footprintDel">确定</view>
  100. </view>
  101. <view v-if="cardModal" class="cancelDel" @click="cardModal = false">
  102. <tui-icon name="close" :size="60" unit="upx" color="#f0f0f0"></tui-icon>
  103. </view>
  104. </tui-modal>
  105. </view>
  106. </template>
  107. <script>
  108. import { deleteFootprintApi, getAllFootprintApi } from '../../../api/anotherTFInterface'
  109. export default {
  110. name: 'FootprintList',
  111. data() {
  112. return {
  113. footprintList: [],
  114. isEmpty: false,
  115. footprintTotal: 0,
  116. queryInfo: {
  117. page: 1,
  118. pageSize: 20
  119. },
  120. options: [ {
  121. name: '删除',
  122. color: '#fff',
  123. fontsize: 32,
  124. width: 80,
  125. background: '#F15C48'
  126. } ],
  127. allCheckShow: false,
  128. isAllCheck: false,
  129. newTimeArr: [],
  130. cardModal: false, // 删除弹窗显示
  131. ids: []
  132. }
  133. },
  134. onShow() {
  135. this.queryInfo.page = 1
  136. this.getFootprintList()
  137. },
  138. methods: {
  139. getFootprintList(isLoadmore) {
  140. uni.showLoading()
  141. getAllFootprintApi(this.queryInfo).then((res) => {
  142. this.footprintTotal = res.data.total
  143. if (isLoadmore) {
  144. this.footprintList.push(...res.data.list)
  145. } else {
  146. this.footprintList = res.data.list
  147. }
  148. this.isEmpty = this.footprintList.length === 0
  149. uni.hideLoading()
  150. })
  151. .catch((e) => {
  152. uni.hideLoading()
  153. })
  154. },
  155. // 滑动删除单个商品足迹
  156. delFootProduction(e) {
  157. if (e.index == 0) {
  158. uni.showLoading()
  159. deleteFootprintApi({
  160. ids: [ this.footprintList[e.item.findex].products[e.item.index].productId ],
  161. times: [ this.footprintList[e.item.findex].createTime ]
  162. }).then((res) => {
  163. uni.hideLoading()
  164. this.$showToast('删除成功')
  165. setTimeout(() => {
  166. this.queryInfo.page = 1
  167. this.getFootprintList()
  168. }, 2000)
  169. })
  170. .catch((e) => {
  171. uni.hideLoading()
  172. })
  173. }
  174. },
  175. // 删除方法
  176. footprintDel() {
  177. uni.showLoading()
  178. this.isAllCheck = false
  179. deleteFootprintApi({
  180. ids: this.ids,
  181. times: this.newTimeArr
  182. }).then((res) => {
  183. this.cardModal = false
  184. this.ids = []
  185. this.newTimeArr = []
  186. uni.hideLoading()
  187. this.$showToast('删除成功')
  188. setTimeout(() => {
  189. this.queryInfo.page = 1
  190. this.getFootprintList()
  191. }, 2000)
  192. })
  193. .catch((e) => {
  194. uni.hideLoading()
  195. })
  196. },
  197. footItemSel(index, findex, state) {
  198. this.footprintList[findex].products[index].selected = state
  199. let footSelectNum = 0
  200. let footprintListlen = 0
  201. const footDataTime = []
  202. this.footprintList.forEach((value, index1) => {
  203. value.products.forEach((value2, index2) => {
  204. if (value2.selected == 0) {
  205. this.isAllCheck = false
  206. } else {
  207. footSelectNum++
  208. footDataTime[index1] = this.footprintList[index1].createTime
  209. }
  210. })
  211. })
  212. this.newTimeArr = footDataTime.filter((d) => d)
  213. this.footprintList.forEach((value, index1) => {
  214. value.products.forEach((value2, index3) => {
  215. footprintListlen++
  216. })
  217. })
  218. if (footprintListlen == footSelectNum) {
  219. this.isAllCheck = true
  220. }
  221. },
  222. // 点击编辑底下删除按钮
  223. showCardModal() {
  224. this.footprintList.forEach((value, index) => {
  225. value.products.forEach((value1, index1) => {
  226. if (value1.selected == 1) {
  227. this.ids.push(value1.productId)
  228. }
  229. if (!this.ids.length) {
  230. this.$showToast('请选择要删除的足迹商品!')
  231. } else {
  232. this.cardModal = true
  233. }
  234. })
  235. })
  236. },
  237. // 全选
  238. allSel(type) {
  239. this.isAllCheck = !this.isAllCheck
  240. this.footprintList.forEach((value, index1) => {
  241. value.products.forEach((value2, index2) => {
  242. value2.selected = type
  243. if (type == 1) {
  244. this.newTimeArr[index1] = this.footprintList[index1].createTime
  245. }
  246. })
  247. })
  248. },
  249. editClick() {
  250. this.allCheckShow = true
  251. this.footprintList.forEach((item) => {
  252. item.products = item.products.map((item) => ({ ...item, selected: 0 }))
  253. })
  254. }
  255. },
  256. onReachBottom() {
  257. if (this.footprintList.length < this.footprintTotal) {
  258. ++this.queryInfo.page
  259. this.getFootprintList(true)
  260. }
  261. }
  262. }
  263. </script>
  264. <style lang="less" scoped>
  265. .footprint-box-container {
  266. min-height: 100vh;
  267. box-sizing: border-box;
  268. background-color: #f7f7f7;
  269. .function-box {
  270. background-color: #FFFFFF;
  271. }
  272. .editicon-box {
  273. display: flex;
  274. justify-content: flex-end;
  275. position: relative;
  276. left: -30rpx;
  277. padding: 16rpx 0;
  278. }
  279. .finishbox {
  280. display: flex;
  281. justify-content: flex-end;
  282. position: relative;
  283. left: -30rpx;
  284. padding: 16rpx 0;
  285. }
  286. .swipe-box {
  287. padding: 0 24rpx;
  288. .listItem {
  289. //padding: 0 24rpx;
  290. background: #F8F8F8;
  291. margin-bottom: 20rpx;
  292. }
  293. .item {
  294. display: flex;
  295. padding: 20rpx;
  296. background: #FFFFFF;
  297. .selectIconBox {
  298. margin-right: 14upx;
  299. display: flex;
  300. align-items: center;
  301. }
  302. }
  303. .product-img {
  304. width: 200rpx;
  305. flex: 0 0 200rpx;
  306. height: 200rpx;
  307. }
  308. .title {
  309. text-align: left;
  310. color: #333333;
  311. height: 150rpx;
  312. }
  313. }
  314. .allcheck-box {
  315. background-color: #FFFFFF;
  316. padding: 10rpx 0;
  317. width: 100%;
  318. position: fixed;
  319. bottom: 0upx;
  320. .left {
  321. display: flex;
  322. flex-direction: row;
  323. align-items: center;
  324. font-size: 28upx;
  325. color: #666;
  326. }
  327. .right {
  328. display: flex;
  329. flex-direction: row;
  330. align-items: center;
  331. box-sizing: border-box;
  332. }
  333. .btn-delete {
  334. width: 232rpx;
  335. height: 100rpx;
  336. background: #C83732;
  337. line-height: 100rpx;
  338. text-align: center;
  339. font-size: 28upx;
  340. color: #FFFFFF;
  341. }
  342. }
  343. .Put-box1 {
  344. .btn {
  345. text-align: center;
  346. margin-top: 40rpx;
  347. border: 1px solid #333333;
  348. height: 80upx;
  349. line-height: 80upx;
  350. width: 100%;
  351. color: #333333;
  352. }
  353. .submit {
  354. background-color: #333333;
  355. color: #FFEBC4;
  356. }
  357. }
  358. .cancelDel {
  359. position: absolute;
  360. bottom: -50px;
  361. left: 45%;
  362. }
  363. }
  364. </style>