knapsack.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <template>
  2. <view class="container">
  3. <view class="tabs">
  4. <uni-transition ref="ani" class="tabsTransition" :styles="styles" :show="true">
  5. <image class="tabsBk" src="@/static/img/knapsack/tabBk.png" mode="widthFix"></image>
  6. </uni-transition>
  7. <view :class="['tab', activeIndex == 1 ? 'active' : '']" @click="tabClick(1)">
  8. 现货奖品
  9. </view>
  10. <view :class="['tab', activeIndex == 2 ? 'active' : '']" @click="tabClick(2)">
  11. 商城订单
  12. </view>
  13. </view>
  14. <view class="list">
  15. <uni-swipe-action :autoClose="false">
  16. <uni-swipe-action-item v-for="(item, index) in list" :key="index" :show="showCheck ? 'left':'none'" :disabled="true">
  17. <template v-slot:left>
  18. <view class="swipeLeft">
  19. <radio class="radio" :checked="item.check == true" @click="checkClick($event, item)" />
  20. </view>
  21. </template>
  22. <view class="card" >
  23. <view class="row" style="margin-top: 10px;">
  24. <view class="left">
  25. <image class="img" src="@/static/img/ka.jpeg" mode="aspectFill"></image>
  26. </view>
  27. <view class="right" style="font-size: 14px;">
  28. <view class="row title">
  29. {{item.prizeName}}
  30. </view>
  31. <view class="row text">
  32. 获得时间:{{ item.creatTime }}
  33. </view>
  34. <view class="row" style="color: #FF2C43;">
  35. 回收积分:{{ item.integral }}
  36. <span class="status">{{ item.prizeStatus }}</span>
  37. </view>
  38. <view class="row button">
  39. <span></span>
  40. <span>
  41. <image style="width: 44px;" src="@/static/img/knapsack/button5.png" mode="widthFix"></image>
  42. </span>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </uni-swipe-action-item>
  48. </uni-swipe-action>
  49. </view>
  50. <view class="buttons" v-if="!showCheck">
  51. <image class="button" src="@/static/img/knapsack/button3.png" mode="heightFix"></image>
  52. <image class="button" @click="showCheck = true" src="@/static/img/knapsack/button4.png" mode="heightFix"></image>
  53. </view>
  54. <view class="bottom" v-if="showCheck">
  55. <view class="left">
  56. <image class="radio1" @click="clickCheckAll(true)" v-if="!allCheck" src="@/static/img/knapsack/check.png" mode="widthFix"></image>
  57. <image class="radio2" @click="clickCheckAll(false)" v-else src="@/static/img/knapsack/checkActive.png" mode="widthFix"></image>
  58. <view class="text" style="color: #000;">
  59. 全选
  60. </view>
  61. <view class="text">
  62. 已选 (<span style="color: #000;">{{selectIndex.length}}</span>)
  63. </view>
  64. </view>
  65. <view class="right">
  66. <image class="button" @click="cancelOrder" style="margin-right: 5px;" src="@/static/img/knapsack/button2.png" mode="heightFix"></image>
  67. <image class="button" @click="toConfirmConfirm" src="@/static/img/knapsack/button1.png" mode="heightFix"></image>
  68. </view>
  69. </view>
  70. </view>
  71. </template>
  72. <script>
  73. import {
  74. packagePrizeListApi
  75. } from "@/api/knapsack.js"
  76. export default {
  77. data() {
  78. return {
  79. showCheck: false,
  80. activeIndex: 1,
  81. list: [],
  82. allCheck: false,
  83. params: {
  84. limit: 999,
  85. page: 1,
  86. status: 0,
  87. },
  88. selectIndex: [],
  89. }
  90. },
  91. onShow() {
  92. this.activeIndex = 1
  93. this.$refs.ani.init({
  94. duration: 100,
  95. timingFunction: 'linear',
  96. transformOrigin: '50% 50%',
  97. show: true,
  98. })
  99. this.$refs.ani.step({
  100. translateX: '0'
  101. })
  102. this.$refs.ani.run(() => {
  103. console.log('动画支持完毕')
  104. })
  105. this.getList()
  106. },
  107. onReady() {
  108. },
  109. onLoad() {
  110. },
  111. watch: {
  112. list: {
  113. deep: true,
  114. handler(newValue, oldValue) {
  115. // console.log(newValue, 'newValue')
  116. let bool = true
  117. for (var i = 0; i < newValue.length; i++) {
  118. if(!newValue[i].check) {
  119. bool = false
  120. }
  121. }
  122. this.allCheck = bool
  123. }
  124. }
  125. },
  126. methods: {
  127. toConfirmConfirm() {
  128. if (this.selectIndex.length == 0) {
  129. wx.showToast({
  130. title: '请选则要发货卡牌。',
  131. icon: 'none',
  132. })
  133. return
  134. }
  135. getApp().globalData.orderConfirmIds = this.selectIndex
  136. getApp().globalData.selectAddrss = null
  137. this.$navigateTo('/pages/orderConfirm/orderConfirm')
  138. },
  139. // 取消下单
  140. cancelOrder() {
  141. this.showCheck = false
  142. this.selectIndex = []
  143. for (var i = 0; i < this.list.length; i++) {
  144. this.list[i].check = false
  145. }
  146. },
  147. clickCheckAll(bool) {
  148. this.selectIndex = []
  149. for (var i = 0; i < this.list.length; i++) {
  150. this.list[i].check = bool
  151. if (bool) {
  152. this.selectIndex.push(this.list[i].id)
  153. }
  154. }
  155. },
  156. checkClick(e, item) {
  157. console.log(item, 'item')
  158. item.check = !item.check
  159. let index = this.selectIndex.indexOf(item.id)
  160. if (item.check && index == -1) {
  161. this.selectIndex.push(item.id)
  162. } else if (!item.check && index != -1) {
  163. this.selectIndex.splice(index, 1)
  164. }
  165. console.log(this.selectIndex, 'this.selectIndex')
  166. },
  167. getList() {
  168. packagePrizeListApi(this.params).then(res => {
  169. console.log(res, '奖品背包')
  170. let list = res.data.list
  171. for (var i = 0; i < list.length; i++) {
  172. list[i].check = false
  173. }
  174. this.list = list
  175. })
  176. },
  177. tabClick(index) {
  178. this.activeIndex = index
  179. if (index == 1) {
  180. this.$refs.ani.step({
  181. translateX: '0'
  182. })
  183. this.$refs.ani.run(() => {
  184. console.log('动画支持完毕')
  185. })
  186. }
  187. if (index == 2) {
  188. this.$refs.ani.step({
  189. translateX: '120px'
  190. })
  191. this.$refs.ani.run(() => {
  192. console.log('动画支持完毕')
  193. })
  194. }
  195. }
  196. }
  197. }
  198. </script>
  199. <style scoped lang="scss">
  200. .container {
  201. background: #9EC8F9;
  202. overflow: auto;
  203. .tabs {
  204. width: 240px;
  205. height: 44px;
  206. border-radius: 22px;
  207. background: rgba(255, 255, 255, 0.8);
  208. margin: 20px auto;
  209. color: #005ECC;
  210. font-size: 14px;
  211. display: flex;
  212. position: relative;
  213. .tabsTransition {
  214. width: 50%;
  215. height: 44px;
  216. position: absolute;
  217. .tabsBk {
  218. width: 100%;
  219. height: 100%;
  220. }
  221. }
  222. .tab {
  223. width: 50%;
  224. height: 44px;
  225. text-align: center;
  226. line-height: 44px;
  227. z-index: 2;
  228. }
  229. .active {
  230. color: #fff;
  231. }
  232. }
  233. .list {
  234. padding: 10px;
  235. padding-bottom: 70px;
  236. .swipeLeft {
  237. display: flex;
  238. align-items: center;
  239. justify-content: center;
  240. width: 40px;
  241. .radio {
  242. transform: scale(0.8);
  243. }
  244. }
  245. .card {
  246. margin-bottom: 10px;
  247. border-radius: 8px;
  248. background: #fff;
  249. padding: 10px;
  250. .row {
  251. display: flex;
  252. justify-content: space-between;
  253. .left {
  254. display: flex;
  255. align-items: center;
  256. .photo {
  257. margin-right: 5px;
  258. width: 30px;
  259. height: 30px;
  260. border-radius: 50%;
  261. }
  262. .name {
  263. font-size: 14px;
  264. font-weight: 600;
  265. }
  266. .img {
  267. width: 100px;
  268. height: 100px;
  269. border-radius: 2px;
  270. margin-right: 10px;
  271. }
  272. }
  273. .right {
  274. flex: 1;
  275. .row {
  276. margin-bottom: 5px;
  277. }
  278. .title {
  279. font-size: 16px;
  280. font-weight: 600;
  281. }
  282. }
  283. .text1 {
  284. color: #666666;
  285. font-size: 12px;
  286. }
  287. }
  288. }
  289. }
  290. .buttons {
  291. position: fixed;
  292. bottom: 0;
  293. display: flex;
  294. justify-content: space-around;
  295. width: 100%;
  296. padding: 10px 0;
  297. image {
  298. height: 42px;
  299. }
  300. }
  301. .bottom {
  302. background: #fff;
  303. position: fixed;
  304. bottom: 0;
  305. display: flex;
  306. justify-content: space-between;
  307. width: calc(100% - 20px);
  308. padding: 10px;
  309. .left {
  310. display: flex;
  311. justify-content: center;
  312. align-items: center;
  313. .text {
  314. color: #999;
  315. font-size: 14px;
  316. margin-left: 10px;
  317. }
  318. .radio1 {
  319. width: 20px;
  320. height: 20px;
  321. }
  322. .radio2 {
  323. width: 18px;
  324. height: 18px;
  325. }
  326. }
  327. .right {
  328. display: flex;
  329. .button {
  330. height: 30px;
  331. }
  332. }
  333. }
  334. }
  335. </style>