ckshop.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <view class="content">
  3. <view class="content2">
  4. <view class="shopBox">
  5. <view class="shopLine" v-for="(item,index) in list" @click="ckshop(item)">
  6. <img src="../../static/img/ckn.png" alt="" class="ckImg" v-if="!item.ck">
  7. <img src="../../static/img/cky.png" alt="" class="ckImg" v-if="item.ck">
  8. <view class="shopName">{{item.shopName}}</view>
  9. </view>
  10. </view>
  11. </view>
  12. <view class="bottom">
  13. <view class="bottomLeft" @click="all">
  14. <img src="../../static/img/ckn.png" alt="" class="ckImg" v-if="!allck">
  15. <img src="../../static/img/cky.png" alt="" class="ckImg" v-if="allck">
  16. <view class="allTxt">全选</view>
  17. </view>
  18. <view class="determine" @click="determine">确定添加</view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. data() {
  25. return {
  26. list:'',
  27. allck:false,
  28. shopckList:'',
  29. }
  30. },
  31. onLoad() {
  32. this.getShopList()
  33. },
  34. methods: {
  35. determine(){
  36. var shopckList=[]
  37. this.list.forEach(item=>{
  38. if(item.ck){
  39. shopckList.push(item)
  40. }
  41. })
  42. uni.setStorage({
  43. key: 'shopckList',
  44. data: shopckList,
  45. success: function () {
  46. uni.navigateBack(-1)
  47. }
  48. });
  49. },
  50. ckshop(item){
  51. item.ck=!item.ck
  52. },
  53. all(){
  54. this.allck=!this.allck;
  55. if(this.allck){
  56. this.list.forEach(item=>{
  57. item.ck=true;
  58. })
  59. }else{
  60. this.list.forEach(item=>{
  61. item.ck=false;
  62. })
  63. }
  64. },
  65. getShopList(){
  66. uni.showLoading({
  67. title: '加载中'
  68. })
  69. this.$http('openH5SetTheGuest/getShopList', {
  70. },'GET').then(res => {
  71. uni.hideLoading();
  72. const shopckList = uni.getStorageSync("shopckList");
  73. // shopckList.forEach(item=>{
  74. // delete item.ck
  75. // })
  76. res.data.forEach(item=>{
  77. item.ck=false;
  78. })
  79. console.log(shopckList)
  80. if(shopckList){
  81. res.data.forEach(item=>{
  82. shopckList.forEach(item2=>{
  83. if(item2.id==item.id){
  84. item.ck=true;
  85. }else{
  86. //item.ck=false;
  87. }
  88. })
  89. // if(shopckList.includes(item)){
  90. // item.ck=true;
  91. // }else{
  92. // item.ck=false;
  93. // }
  94. })
  95. }else{
  96. }
  97. this.list=res.data;
  98. console.log(this.list)
  99. })
  100. }
  101. }
  102. }
  103. </script>
  104. <style scoped>
  105. .content{
  106. min-height: 100vh;
  107. background:#F4F5F7;
  108. }
  109. .shopBox{
  110. background: #ffffff;
  111. border-radius: 10rpx;
  112. }
  113. .content2{
  114. padding: 20rpx 24rpx;
  115. padding-bottom: 140rpx;
  116. }
  117. .shopLine{
  118. display: flex;
  119. padding: 30rpx 20rpx;
  120. border-bottom: 1px solid #EEEEEE;
  121. }
  122. .ckImg{
  123. width: 44rpx;
  124. height: 44rpx;
  125. }
  126. .shopName{
  127. color: #3C3C3C;
  128. line-height: 44rpx;
  129. font-size: 28rpx;
  130. padding-left: 26rpx;
  131. }
  132. .bottom{
  133. width: 750rpx;
  134. height: 120rpx;
  135. background: #FFFFFF;
  136. position: fixed;
  137. left: 0;
  138. bottom: 0;
  139. display: flex;
  140. justify-content: space-between;
  141. }
  142. .bottomLeft{
  143. display: flex;
  144. padding-top: 38rpx;
  145. padding-left: 24rpx;
  146. }
  147. .allTxt{
  148. line-height: 44rpx;padding-left: 12rpx;color: #3C3C3C;
  149. }
  150. .determine{
  151. width: 310rpx;
  152. height: 98rpx;
  153. background: #3F90F7;
  154. border-radius: 10rpx;
  155. font-weight: 500;
  156. color: #FFFFFF;
  157. font-size: 31rpx;
  158. line-height: 98rpx;
  159. text-align: center;
  160. margin-top: 11rpx;
  161. margin-right: 24rpx;
  162. }
  163. </style>