index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <view>
  3. <!-- #ifdef MP-ALIPAY -->
  4. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="选择盲票天使" leftIconSize="0">
  5. </u-navbar>
  6. <!-- #endif -->
  7. <!-- #ifndef MP-ALIPAY -->
  8. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="选择盲票天使"></u-navbar>
  9. <!-- #endif -->
  10. <view class="coupon-title">
  11. <u-search placeholder="请输入名字或工号" v-model="searchValue" @blur="pageList()" :showAction="false"></u-search>
  12. </view>
  13. <view class="coupon-list">
  14. <u-radio-group v-model="radiovalue1" placement="column" @change="changeChechk()">
  15. <view class="flex coupon-list-item" v-for="(item,index) in list" :key="index">
  16. <view class="block">
  17. <view class="title">{{item.name}}</view>
  18. <text>工号:{{item.workNo}}</text>
  19. </view>
  20. <view class="uradio">
  21. <u-radio :customStyle="{ marginBottom: '8px' }" :name="item.channelId" activeColor="#E96737"
  22. size="24">
  23. </u-radio>
  24. </view>
  25. </view>
  26. <u-loadmore :line="true" v-if="list.length>20" :status="status" :loading-text="'努力加载中'"
  27. :nomore-text="'已经到底了'" />
  28. </u-radio-group>
  29. </view>
  30. <view class="footer-fixed">
  31. <view class="flex btn">
  32. <button type="default" @click="exchange">确认</button>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import env from '../../config/env.js'
  39. import appId from '@/config/appId.js'
  40. import $http from '@/utils/request.js'
  41. export default {
  42. data() {
  43. return {
  44. pageNum: 1,
  45. total: 0,
  46. list: [],
  47. radiovalue1: '', //选中项的下标
  48. channelId: '', //选中项的id
  49. id: '', //门店的channelId
  50. status: 'nomore', //上拉刷新状态
  51. searchValue: '', //搜索
  52. };
  53. },
  54. onShow() {
  55. this.pageList()
  56. },
  57. onLoad(opthios) {
  58. if (opthios.channelId) {
  59. this.id = opthios.channelId
  60. this.channelId = opthios.index
  61. this.radiovalue1 = Number(opthios.index)
  62. }
  63. },
  64. methods: {
  65. pageList() {
  66. this.list = []
  67. this.pageNum = 1
  68. this.getList()
  69. },
  70. getList() {
  71. let _this = this
  72. $http.post(`/api/v1/mp/channel/promoter/list?pageNum=${_this.pageNum}&pageSize=20`, {
  73. channelId: this.id,
  74. searchValue: this.searchValue,
  75. }).then(
  76. res => {
  77. if (res.code == 0) {
  78. this.total = res.total
  79. this.list = [...this.list, ...res.rows]
  80. }
  81. }).catch(() => {})
  82. },
  83. // 点击切换事件
  84. changeChechk(e) {
  85. if (this.channelId == e) {
  86. this.radiovalue1 = -1
  87. this.channelId = ''
  88. return
  89. } else {
  90. this.channelId = e
  91. return
  92. }
  93. },
  94. // 点击确认事件
  95. exchange() {
  96. let promoters = {}
  97. for (var i = 0; i < this.list.length; i++) {
  98. if (this.list[i].channelId == this.channelId) {
  99. promoters = {
  100. channelId: this.channelId,
  101. name: this.list[i].name,
  102. workNo: this.list[i].workNo,
  103. }
  104. }
  105. }
  106. uni.$emit('promoters', promoters)
  107. uni.navigateBack({
  108. delta: 1
  109. })
  110. }
  111. },
  112. onReachBottom() {
  113. // 判断是否有数据
  114. if (this.total < this.pageNum * 20) return;
  115. this.status = 'loading';
  116. ++this.pageNum
  117. if (this.total < this.pageNum * 20) this.status = 'nomore';
  118. else this.status = 'loading';
  119. this.getList()
  120. },
  121. }
  122. </script>
  123. <style lang="scss" scoped>
  124. .coupon {
  125. &-title {
  126. position: fixed;
  127. z-index: 10;
  128. width: 100%;
  129. padding: 24rpx 32rpx;
  130. background-color: #FFFFFF;
  131. }
  132. &-list {
  133. margin-top: 110rpx;
  134. &-item {
  135. justify-content: space-between;
  136. padding: 20rpx 50rpx;
  137. background-color: #FFFFFF;
  138. margin-bottom: 20rpx;
  139. background-size: 100%;
  140. .block {
  141. color: #333;
  142. .title {
  143. line-height: 60rpx;
  144. font-size: 32rpx;
  145. }
  146. text {
  147. font-size: 26rpx;
  148. }
  149. }
  150. .uradio {
  151. position: absolute;
  152. right: 40rpx;
  153. }
  154. .circle {
  155. width: 40rpx;
  156. height: 40rpx;
  157. border-radius: 50%;
  158. border: 1px solid;
  159. }
  160. .action {
  161. width: 30rpx;
  162. height: 30rpx;
  163. border-radius: 50%;
  164. background-color: $uni-bg-color;
  165. }
  166. }
  167. }
  168. }
  169. .footer-fixed {
  170. position: fixed;
  171. bottom: var(--window-bottom);
  172. left: 0;
  173. right: 0;
  174. z-index: 11;
  175. box-shadow: 0 -4rpx 40rpx 0 rgba(151, 151, 151, 0.24);
  176. background: #fff;
  177. // 设置ios刘海屏底部横线安全区域
  178. padding-bottom: constant(safe-area-inset-bottom);
  179. padding-bottom: env(safe-area-inset-bottom);
  180. .btn {
  181. padding: 20rpx 0;
  182. ::v-deep button {
  183. width: 441rpx;
  184. height: 88rpx;
  185. line-height: 88rpx;
  186. font-size: 36rpx;
  187. color: #fff;
  188. background-color: #F9822C;
  189. border: none;
  190. border-radius: 44rpx;
  191. }
  192. }
  193. }
  194. </style>