storeUsers.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <view class="creat">
  3. <cu-custom bgColor="bg-fff" :isBack="true">
  4. <block slot="content">本店用户</block>
  5. </cu-custom>
  6. <view class="top"></view>
  7. <view class="content">
  8. <view class="product-item" v-for="(item, index) in userList" :key="index"
  9. @click="handleRadioChange(item.id)">
  10. <view class="product-info">
  11. <image style="width:68rpx;height:68rpx;margin-right:16rpx" :src="item.userAvatar" mode=""></image>
  12. {{ item.nickName }}
  13. </view>
  14. <view v-if="selectedIds.indexOf(item.id) == '-1'" class="radio-container"></view>
  15. <image v-else class="radio-img" src="/static/coupon/danxuan.png" mode=""></image>
  16. </view>
  17. </view>
  18. <view class="btn">
  19. <view class="flex">
  20. <view @click="groupChange(1)" class="flex">
  21. <text v-if="!selectAll" style="display: inline-block;" class="radio-container"></text>
  22. <image v-else style=" vertical-align: top" class="radio-img" src="/static/coupon/quanxuan.png"
  23. mode=""></image>
  24. <text style="margin-left:10rpx">全选</text>
  25. </view>
  26. <view @click="groupChange(2)" class="flex" style="margin-left:36rpx">
  27. <text v-if="!invertAll" style="display: inline-block;" class="radio-container"></text>
  28. <image v-else style=" vertical-align: top;" class="radio-img" src="/static/coupon/danxuan.png"
  29. mode=""></image>
  30. <text style="margin-left:10rpx">反选</text>
  31. </view>
  32. </view>
  33. <button class="cu-btn submit round " @click="submit">确定发放</button>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import { USER_INFO } from "@/common/util/constants"
  39. export default {
  40. data() {
  41. return {
  42. selectAll: false,
  43. invertAll: false,
  44. userList: [], // 用户列表
  45. selectedIds: [], // 当前选中的商品ID组
  46. productName: '',
  47. outsideRow:{}
  48. }
  49. },
  50. onLoad(e) {
  51. this.outsideRow=JSON.parse(decodeURIComponent(e.params))
  52. this.getList()
  53. },
  54. methods: {
  55. getList() {
  56. this.$http.get('/merchant/localVoucherInfo/getUser?merchantId='+ uni.getStorageSync(USER_INFO).merchantId).then(res => {
  57. if (res.data.success) {
  58. this.userList =res.data.result
  59. }
  60. else {
  61. this.$tip.error(res.data.message);
  62. }
  63. })
  64. },
  65. groupChange(e) {
  66. if (e == 1) {
  67. this.selectedIds = !this.selectAll ? this.userList.map(item => item.id) : []
  68. this.selectAll = !this.selectAll
  69. }
  70. if (e == 2) {
  71. this.invertAll = !this.invertAll
  72. }
  73. },
  74. searchList() {
  75. this.getList()
  76. },
  77. // 确认
  78. submit() {
  79. if (this.selectedIds.length > 0) {
  80. let data={
  81. merchantId: uni.getStorageSync(USER_INFO).merchantId,
  82. // type:'3',
  83. userIds:this.selectedIds,
  84. ...this.outsideRow
  85. }
  86. this.$http.post('/merchant/localConsumerUserInfo/addStoreUserOut', data).then(res => {
  87. if (res.data.success) {
  88. this.$tip.error(res.data.message||'发放成功');
  89. uni.navigateBack({
  90. delta: 1
  91. });
  92. }
  93. else {
  94. this.$tip.error(res.data.message);
  95. }
  96. })
  97. }
  98. },
  99. // 单选按钮变化处理
  100. handleRadioChange(id) {
  101. // 判断是否已存在
  102. const index = this.selectedIds.indexOf(id)
  103. if (index > -1) {
  104. // 如果存在则删除
  105. this.selectedIds.splice(index, 1)
  106. } else {
  107. // 如果不存在则添加
  108. this.selectedIds.push(id)
  109. }
  110. // if (e) {
  111. // this.selectedId.push(item.id);
  112. // } else {
  113. // this.selectedId
  114. // }
  115. },
  116. }
  117. }
  118. </script>
  119. <style scoped lang="scss">
  120. .creat {
  121. width: 100vw;
  122. height: 100vh;
  123. background: #F7F8FC;
  124. display: flex;
  125. flex-direction: column;
  126. justify-content: space-between;
  127. }
  128. .top {
  129. width: 100%;
  130. height: var(--status-bar-height);
  131. background-color: #fff;
  132. }
  133. .content {
  134. width: 100%;
  135. flex: 1;
  136. // padding: 24rpx;
  137. overflow-y: auto;
  138. }
  139. .btn {
  140. width: 100%;
  141. padding: 18rpx 26rpx;
  142. height: 112rpx;
  143. background-color: #fff;
  144. display: flex;
  145. justify-content: space-between;
  146. align-items: center;
  147. .submit {
  148. color: #fff;
  149. width: 205rpx;
  150. text-align: center;
  151. background: linear-gradient(90deg, #77B6FF 0%, #449AFF 100%);
  152. }
  153. }
  154. .product-item {
  155. display: flex;
  156. justify-content: space-between;
  157. align-items: center;
  158. padding: 24rpx;
  159. background: #FFFFFF;
  160. // margin-bottom: 20rpx;
  161. border-bottom: 1px solid #EEEEEE;
  162. }
  163. .product-info {
  164. display: flex;
  165. align-items: center;
  166. flex: 1;
  167. }
  168. .product-image {
  169. width: 120rpx;
  170. height: 120rpx;
  171. border-radius: 8rpx;
  172. margin-right: 20rpx;
  173. }
  174. .product-details {
  175. flex: 1;
  176. }
  177. .product-name {
  178. font-size: 28rpx;
  179. color: #333333;
  180. margin-bottom: 8rpx;
  181. }
  182. .product-date {
  183. font-size: 24rpx;
  184. color: #999999;
  185. margin-bottom: 8rpx;
  186. }
  187. .product-price {
  188. display: flex;
  189. align-items: baseline;
  190. }
  191. .actual-price {
  192. font-size: 32rpx;
  193. color: #FF4B33;
  194. font-weight: bold;
  195. margin-right: 12rpx;
  196. }
  197. .original-price {
  198. font-size: 24rpx;
  199. color: #999999;
  200. text-decoration: line-through;
  201. }
  202. .radio-container {
  203. width: 40rpx;
  204. height: 40rpx;
  205. border-radius: 50%;
  206. border: 1px solid #B4B4B4;
  207. }
  208. .radio-img {
  209. width: 40rpx;
  210. height: 40rpx;
  211. }
  212. ::v-deep .u-radio {
  213. margin-left: 20rpx;
  214. }
  215. </style>