addBind.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <view class="container">
  3. <view class="app-body">
  4. <!--关键词搜索-->
  5. <view class="sreach fx-r fx-bc fx-ac">
  6. <image class="icon" src="/static/img/tb-seach.png"></image>
  7. <input type="text" v-model="keyword" placeholder="请输入用户UID" placeholder-style="color: #B3B3B3;" />
  8. <view class="fx-g1"></view>
  9. <view class="search-btn" @tap="tapSerach">搜索</view>
  10. </view>
  11. <view class="inputForm">
  12. <view class="flex inputBox">
  13. <view class="">会员1</view>
  14. <input type="text" v-model="uid1" placeholder="请输入用户UID" placeholder-style="color: #B3B3B3;" />
  15. <image src="/static/img/m_close.png" style="width: 30rpx;height: 30rpx;" @click="uid1 = ''"></image>
  16. </view>
  17. <view class="flex inputBox">
  18. <view class="">会员2</view>
  19. <input type="text" v-model="uid2" placeholder="请输入用户UID" placeholder-style="color: #B3B3B3;" />
  20. <image src="/static/img/m_close.png" style="width: 30rpx;height: 30rpx;" @click="uid2 = ''"></image>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="listBox">
  25. <view class="listTop flex">
  26. <view class="tpls" style="width: 25%;">uid</view>
  27. <view class="tpls" style="width: 25%;">头像</view>
  28. <view class="tpls" style="width: 25%;">昵称</view>
  29. <view class="tpls" style="width: 25%;">操作</view>
  30. </view>
  31. <!-- #ifdef APP-PLUS -->
  32. <scroll-view scroll-y class="scroll" style="height: calc(100vh - 260px)"
  33. @scrolltolower="loadMoreData">
  34. <!-- #endif -->
  35. <!-- #ifdef H5 -->
  36. <scroll-view scroll-y class="scroll" style="height: calc(100vh - 300px)"
  37. @scrolltolower="loadMoreData">
  38. <!-- #endif -->
  39. <view class="sc-body">
  40. <view class="item flex" v-for="(item,index) in listAr" :key="index">
  41. <view class="items" style="width: 25%;">{{item.uid}}</view>
  42. <view class="items" style="width: 25%;">
  43. <image :src="item.avatar" style="width: 80rpx;height: 80rpx;border-radius: 100%;background: #999;"></image>
  44. </view>
  45. <view class="items nickname" style="width:25%;">{{item.nickname}}</view>
  46. <view class="items" style="width: 25%;" @click="checkTap(item.uid)">
  47. <image src="/static/img/radio_buttons_btn.png" style="width: 40rpx;height: 40rpx;"></image>
  48. </view>
  49. </view>
  50. <view v-if="listAr.length > 0">
  51. <view class="loading fx-r fx-ac fx-bc" v-if="page.isFrite && !page.isFoot">
  52. <image src="/static/img/xloading.png"></image>
  53. <text>正在载入更多...</text>
  54. </view>
  55. <view class="loading complete" :hidden="!page.isFoot">已加载全部</view>
  56. </view>
  57. <view v-if="listAr.length == 0 && isFirst">
  58. <uv-empty mode="data" icon="/static/img/no-empty.png"></uv-empty>
  59. </view>
  60. </view>
  61. </scroll-view>
  62. </view>
  63. <view class="addBtn" @tap="addBind()">确认绑定</view>
  64. </view>
  65. </template>
  66. <script>
  67. export default {
  68. data() {
  69. return{
  70. uid1:'',
  71. uid2:'',
  72. keyword:'',
  73. listAr:[],
  74. isFirst: false,
  75. page: {
  76. isFirst: false,
  77. isLoad: false,
  78. isFoot: false,
  79. page: 1
  80. },
  81. };
  82. },
  83. onLoad() {
  84. this.getList(true)
  85. },
  86. onShow() {},
  87. methods: {
  88. addBind(){
  89. let obj = this
  90. uni.showModal({
  91. title: '提示',
  92. content: '你确定要绑定吗?',
  93. success: function (res) {
  94. if (res.confirm) {
  95. uni.showLoading({
  96. title: '绑定中...'
  97. });
  98. obj.request.post("bind",{
  99. uid1:obj.uid1,
  100. uid2: obj.uid2,
  101. }).then(res => {
  102. uni.showModal({
  103. title: '系统提示',
  104. content: res.msg,
  105. showCancel: false
  106. });
  107. obj.uid1 = ''
  108. obj.uid2 = ''
  109. uni.hideLoading();
  110. }).catch(res=>{
  111. console.log(res);
  112. uni.hideLoading();
  113. uni.showModal({
  114. title: '系统提示',
  115. content: '加载失败,返回在尝试',
  116. showCancel: false
  117. });
  118. });
  119. } else if (res.cancel) {
  120. console.log('用户点击取消');
  121. }
  122. }
  123. });
  124. },
  125. checkTap(uid){
  126. if(this.uid1 == ''){
  127. this.uid1 = uid
  128. }else{
  129. this.uid2 = uid
  130. }
  131. },
  132. tapSerach: function() {
  133. this.getList(true);
  134. },
  135. getList(isPull = false){
  136. if (this.page.isLoad) return;
  137. this.page.isLoad = true;
  138. if (isPull) {
  139. this.page.page = 1;
  140. this.page.isLoad = false;
  141. this.page.isFoot = false;
  142. }
  143. uni.showLoading({
  144. title: '获取数据中..'
  145. });
  146. this.request.post("gzUserList",{
  147. keyword:this.keyword,//手机号
  148. page: this.page.page,
  149. }).then(res => {
  150. uni.hideLoading();
  151. this.page.isFirst = true;
  152. this.page.isLoad = false;
  153. this.isFirst = true;
  154. if (isPull) {
  155. this.listAr = res.data.list;
  156. } else {
  157. this.listAr = this.listAr.concat(res.data.list);
  158. }
  159. //是否到底
  160. if (res.data.list.length != res.data.pageSize) {
  161. this.page.isFoot = true;
  162. }
  163. }).catch(res=>{
  164. console.log(res);
  165. uni.hideLoading();
  166. uni.showModal({
  167. title: '系统提示',
  168. content: '加载失败,返回在尝试',
  169. showCancel: false
  170. });
  171. });
  172. },
  173. loadMoreData() {
  174. if (this.page.isFoot || this.page.isLoad) {
  175. return;
  176. }
  177. this.page.page++;
  178. this.getList();
  179. },
  180. },
  181. };
  182. </script>
  183. <style lang="scss" scoped>
  184. .flex {
  185. display: flex;
  186. align-items: center;
  187. justify-content: space-between;
  188. }
  189. .flex_item {
  190. display: flex;
  191. align-items: center;
  192. }
  193. .app-body {
  194. padding: 0px 20rpx 20rpx 20rpx;
  195. background: #fff;
  196. .sreach {
  197. background: #eee;
  198. border-radius: 32rpx;
  199. padding: 16rpx 32rpx;
  200. .icon {
  201. width: 46rpx;
  202. height: 46rpx;
  203. }
  204. input {
  205. width: calc(100% - 46rpx - 16rpx - 50px);
  206. font-size: 16px;
  207. }
  208. .search-btn {
  209. font-size: 14px;
  210. color: #FF4C4C;
  211. }
  212. }
  213. }
  214. .inputForm{
  215. background: #fff;
  216. font-size: 24rpx;
  217. .inputBox{
  218. padding-top: 25rpx;
  219. .btns{
  220. color: red;
  221. }
  222. }
  223. }
  224. .addBtn{
  225. position: fixed;
  226. background: linear-gradient(89deg, #FF332C, #FF6030);
  227. border-radius: 10rpx;
  228. bottom: 25rpx;
  229. width: 90%;
  230. line-height: 80rpx;
  231. font-weight: bold;
  232. font-size: 29rpx;
  233. color: #FFFFFF;
  234. margin: 0 5%;
  235. text-align: center;
  236. }
  237. .listBox{
  238. .listTop{
  239. padding: 25rpx;
  240. background: #F7C4C4;
  241. margin-bottom: 25rpx;
  242. .tpls{
  243. text-align: center;
  244. }
  245. }
  246. }
  247. .item{
  248. .items{
  249. text-align: center;
  250. }
  251. .nickname{
  252. font-size: 24rpx;
  253. }
  254. }
  255. </style>