circle.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  1. <template>
  2. <view class="content">
  3. <view class="content1 flex flex-between">
  4. <view class="search flex">
  5. <view class="left flex" @click="search">
  6. <image src="../../static/imgs/cirlce/search.png" mode="widthFix" class="search-img"></image>
  7. <text class="search-val"> {{searchVal?searchVal:'搜索圈子'}}</text>
  8. <image class='search-del' style='width:32rpx;height:32rpx;' v-if="searchVal"
  9. @click.native.stop="delSearchVal" src="../../static/imgs/card/searchdel.png" mode="widthFix">
  10. </image>
  11. </view>
  12. </view>
  13. <view class="right relative">
  14. <image src="../../static/imgs/cirlce/hy.png" mode="widthFix" class="hy-search-img"
  15. @click="toChangeCard"></image>
  16. <u-badge v-if='cardList.length>0' :isDot="true" type="error" class="point position"></u-badge>
  17. </view>
  18. </view>
  19. <mescroll-uni ref="mescrollRef" :top="120" :up="upOption" :down="downOption" @init="mescrollInit" @up="upCallback"
  20. @down="downCallback">
  21. <view class="content2 flex flex-between">
  22. <view class="left flex title">
  23. <view class="line"></view>
  24. <view class="text-title">
  25. 我的圈子
  26. </view>
  27. </view>
  28. <!-- <view class="right">
  29. <uni-icons type="personadd-filled" size="30" @click="toCreateCircle"></uni-icons>
  30. </view> -->
  31. </view>
  32. <view class="wd-list">
  33. <view v-for="(item,index) in circleList1" :key="index">
  34. <view class="flex title" v-if="item.name">
  35. <view class="line"></view>
  36. <view class="text-title">
  37. {{item.name}}
  38. </view>
  39. </view>
  40. <view class="row-tiem flex" v-if="!item.name" @click="toDetail(item.id)">
  41. <view class="left">
  42. <image :src="item.circleHead?item.circleHead:'../../static/imgs/mySet/ewm.png'"
  43. mode="aspectFill" class="img"></image>
  44. </view>
  45. <view class="right">
  46. <view class="top">{{item.circleName}}({{item.cardNum}}人)</view>
  47. <view style='flex-wrap: wrap;' class="bottom flex">
  48. <view v-for="item1 in item.circleLabelArray" class="text">
  49. {{item1}}
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="content2 flex flex-between">
  57. <view class="left flex title">
  58. <view class="line"></view>
  59. <view class="text-title">
  60. 推荐圈子
  61. </view>
  62. </view>
  63. <!-- <view class="right">
  64. <uni-icons type="personadd-filled" size="30" @click="toCreateCircle"></uni-icons>
  65. </view> -->
  66. </view>
  67. <view class="tj-list">
  68. <view v-for="(item,index) in circleList" :key="index">
  69. <view class="flex title" v-if="item.name">
  70. <view class="line"></view>
  71. <view class="text-title">
  72. {{item.name}}
  73. </view>
  74. </view>
  75. <view class="row-tiem flex" v-if="!item.name" @click="toDetail(item.id)">
  76. <view class="left">
  77. <image :src="item.circleHead?item.circleHead:'../../static/imgs/mySet/ewm.png'"
  78. mode="aspectFill" class="img"></image>
  79. </view>
  80. <view class="right">
  81. <view class="top">{{item.circleName}}({{item.cardNum}}人)</view>
  82. <view style='flex-wrap: wrap;' class="bottom flex">
  83. <view v-for="item1 in item.circleLabelArray" class="text">
  84. {{item1}}
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. </mescroll-uni>
  92. <image src="../../static/imgs/cirlce/add.png" mode="widthFix" class="add" @click="toCreateCircle"></image>
  93. <u-toast ref="uToast"></u-toast>
  94. <!-- #ifdef MP-WEIXIN -->
  95. <u-modal :show="showAuthorizePhone" :showConfirmButton="false">
  96. <view class="slot-content">
  97. <view class="auth-card">
  98. <view class="img">
  99. <img class="avatar-img" src="@/static/imgs/logo.png" mode="widthFix">
  100. </view>
  101. <view class="content">手机登录后才能查看名片哦~</view>
  102. </view>
  103. <view class="auth-btncard">
  104. <view class="btn-unok">
  105. <u-button :customStyle="customStyleUnOk" @click="showAuthorizePhone=false" :plain="true">
  106. 拒绝</u-button>
  107. </view>
  108. <view class="btn-ok">
  109. <u-button :customStyle="customStyleOk" open-type="getPhoneNumber"
  110. @getphonenumber="getPhoneNumber"> 立即登录</u-button>
  111. </view>
  112. </view>
  113. </view>
  114. </u-modal>
  115. <u-modal :show="showAuthorizeUser" :showConfirmButton="false">
  116. <view class="slot-content">
  117. <view class="auth-card">
  118. <view class="img">
  119. <img class="avatar-img" src="/static/imgs/logo.png" mode="widthFix">
  120. </view>
  121. <view class="content">邀请您补全个人信息<br></br>(昵称、头像)</view>
  122. <view style="margin-left: 100rpx;margin-right: 100rpx">
  123. <u-form :model="userInfo" ref="uForm">
  124. <u-form-item label="头像">
  125. <button class="avatar-wrapper" open-type="chooseAvatar" @chooseavatar="onChooseAvatar"
  126. slot="right">
  127. <image class="avatar"
  128. :src="userInfo.head?userInfo.head:'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'">
  129. </image>
  130. </button>
  131. </u-form-item>
  132. <u-form-item label="昵称">
  133. <u-input inputAlign='right' v-model="userInfo.nickname" class="weui-input"
  134. @blur="userNameInput" placeholder="请输入昵称" border="false" />
  135. <!-- <input type="nickname" :value="userInfo.nickname" class="weui-input" @blur="userNameInput" placeholder="请输入昵称"/> -->
  136. </u-form-item>
  137. </u-form>
  138. </view>
  139. </view>
  140. <view class="auth-btncard">
  141. <view class="btn-unok"><u-button :customStyle="customStyleUnOk" @click="authUser(0)">
  142. 拒绝</u-button>
  143. </view>
  144. <view class="btn-ok">
  145. <u-button :customStyle="customStyleOk" @click="authUser(1)"> 允许</u-button>
  146. </view>
  147. </view>
  148. </view>
  149. </u-modal>
  150. <!-- #endif -->
  151. </view>
  152. </template>
  153. <script>
  154. var that;
  155. import {
  156. pathToBase64,
  157. base64ToPath
  158. } from 'image-tools'
  159. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  160. import {
  161. mapState,
  162. mapMutations
  163. } from 'vuex';
  164. export default {
  165. mixins: [MescrollMixin], // 使用mixin
  166. computed: {
  167. ...mapState(['hasLogin'])
  168. },
  169. data() {
  170. return {
  171. showAuthorizeUser: false,
  172. showAuthorizePhone: false,
  173. customStyleUnOk: {
  174. marginTop: '20rpx',
  175. color: '#18254C',
  176. border: '2px solid #18254C',
  177. "border-radius": "10px",
  178. fontSize: "32rpx"
  179. },
  180. customStyleOk: {
  181. marginTop: '20rpx',
  182. color: '#fff',
  183. border: '2px solid #18254C',
  184. "border-radius": "10px",
  185. fontSize: "32rpx",
  186. background: "#18254C"
  187. },
  188. searchVal: '',
  189. circleList: [],
  190. userInfo: {},
  191. canReset: false,
  192. cardList: [],
  193. circleList1: [],
  194. downOption: {
  195. auto: false,
  196. textColor: '#bbb'
  197. },
  198. upOption: {
  199. page: {
  200. size: 10 // 每页数据的数量,默认10
  201. },
  202. auto: false,
  203. noMoreSize: 1,
  204. textNoMore: '没有更多了~',
  205. textColor: '#bbb'
  206. }
  207. };
  208. },
  209. onLoad() {
  210. that = this
  211. if (uni.getStorageSync("userInfo").phone) {
  212. this.userInfo = uni.getStorageSync("userInfo")
  213. this.$nextTick(function() {
  214. that.mescroll.resetUpScroll()
  215. });
  216. this.$request.baseRequest('admin.unimall.cardExchangeInfo', 'list', {
  217. receiveId: this.userInfo.id,
  218. status: 1
  219. }, failres => {
  220. console.log('res+++++', failres.errmsg)
  221. uni.showToast({
  222. icon: "none",
  223. title: failres.errmsg,
  224. duration: 3000
  225. });
  226. }).then(res => {
  227. this.cardList = res.data.items.filter((item) => {
  228. return item.status == 0
  229. })
  230. console.log(this.cardList)
  231. })
  232. }
  233. },
  234. onShow() {
  235. if (uni.getStorageSync("userInfo").phone) {
  236. this.userInfo = uni.getStorageSync("userInfo")
  237. this.$request.baseRequest('admin.unimall.cardExchangeInfo', 'list', {
  238. receiveId: this.userInfo.id,
  239. status: 1
  240. }, failres => {
  241. console.log('res+++++', failres.errmsg)
  242. uni.showToast({
  243. icon: "none",
  244. title: failres.errmsg,
  245. duration: 3000
  246. });
  247. }).then(res => {
  248. this.searchVal = uni.getStorageSync("cirlce_search_val") ? uni.getStorageSync(
  249. "cirlce_search_val") : ''
  250. if (this.searchVal) this.mescroll.resetUpScroll();
  251. })
  252. } else {
  253. this.showAuthorizePhone = true
  254. }
  255. },
  256. methods: {
  257. //获取昵称输入内容
  258. userNameInput(e) {
  259. this.userInfo.nickname = e.detail.value
  260. },
  261. async onChooseAvatar(e) {
  262. this.$set(this.userInfo, "head", await this.toBase64(e.detail.avatarUrl))
  263. },
  264. toBase64(url) {
  265. return new Promise(resolve => {
  266. pathToBase64(url).then(path => {
  267. resolve(path);
  268. }).catch(error => {
  269. console.log(error)
  270. })
  271. })
  272. },
  273. async authUser(type) {
  274. //同步信息,没有头像和昵称自动生成
  275. this.userInfo = await this.$request.syncInfo(this.userInfo)
  276. if(this.userInfo.openId) {
  277. uni.setStorageSync("userInfo", that.userInfo)
  278. that.showAuthorizeUser = false
  279. that.mescroll.resetUpScroll()
  280. }
  281. },
  282. downCallback() {
  283. if (uni.getStorageSync("userInfo").phone) {
  284. this.mescroll.resetUpScroll()
  285. } else {
  286. this.mescroll.endBySize(0, 0)
  287. this.showAuthorizePhone = true
  288. }
  289. },
  290. async getPhoneNumber(e) {
  291. that.userInfo = await this.$request.wxlogin()
  292. this.$nextTick(function() {
  293. that.userInfo.phone = that.$request.getPhone(e, that.userInfo)
  294. that.showAuthorizePhone = false
  295. that.showAuthorizeUser = true
  296. });
  297. },
  298. delSearchVal() {
  299. this.searchVal = ""
  300. uni.removeStorageSync('cirlce_search_val')
  301. this.mescroll.resetUpScroll()
  302. },
  303. toChangeCard() {
  304. if (this.userInfo.phone) {
  305. uni.navigateTo({
  306. url: "/pageA/circle/changeCard"
  307. })
  308. } else {
  309. this.showAuthorizePhone = true
  310. }
  311. },
  312. toCreateCircle() {
  313. if (this.userInfo.phone) {
  314. uni.navigateTo({
  315. url: "/pageA/circle/createCirclce"
  316. })
  317. } else {
  318. this.showAuthorizePhone = true
  319. }
  320. },
  321. micOpen: function() {
  322. this.$refs.asr.show();
  323. },
  324. search() {
  325. if (this.userInfo.phone) {
  326. uni.navigateTo({
  327. url: "/pageA/circle/search"
  328. })
  329. } else {
  330. this.showAuthorizePhone = true
  331. }
  332. },
  333. toDetail(val) {
  334. uni.navigateTo({
  335. url: "/pageA/circle/detail?val=" + val
  336. })
  337. },
  338. upCallback(page) {
  339. uni.showLoading({
  340. title: '数据加载中'
  341. })
  342. let _data = {
  343. commonId: this.userInfo.id,
  344. page: page.num,
  345. limit: page.size,
  346. status: 1
  347. }
  348. if (this.searchVal) {
  349. _data.circleName = this.searchVal
  350. }
  351. this.$request.baseRequest('admin.unimall.circleManagementInfo', 'list', _data, failres => {
  352. console.log('res+++++', failres.errmsg)
  353. uni.showToast({
  354. icon: "none",
  355. title: failres.errmsg,
  356. duration: 3000
  357. });
  358. uni.hideLoading()
  359. }).then(res => {
  360. uni.hideLoading()
  361. console.log(11)
  362. let curPageData = res.data.items;
  363. let totalPage = res.data.total;
  364. let curPageLen = curPageData.length;
  365. this.mescroll.endByPage(curPageLen, totalPage);
  366. console.log(res.data)
  367. // this.makeData(res.data)
  368. //追加新数据
  369. for (let i = 0; i < this.circleList.length; i++) {
  370. if (this.circleList[i].circleLabel) {
  371. if (this.circleList[i].circleLabel.split(',').length >= 3) {
  372. var arr = this.circleList[i].circleLabel.split(',')
  373. console.log(arr)
  374. this.circleList[i].circleLabelArray = arr.filter((item, index) => {
  375. return index <= 2
  376. })
  377. } else {
  378. this.circleList[i].circleLabelArray = this.circleList[i].circleLabel.split(',')
  379. }
  380. }
  381. }
  382. if (page.num == 1) this.circleList1 = [];
  383. this.circleList = []; //如果是第一页需手动置空列表
  384. var tjarr = curPageData.filter((item) => {
  385. return item.addedFlag == 0
  386. })
  387. var wdarr = curPageData.filter((item) => {
  388. return item.addedFlag == 1
  389. })
  390. this.circleList1 = this.circleList1.concat(wdarr);
  391. this.circleList = this.circleList.concat(tjarr);
  392. })
  393. },
  394. input(res) {
  395. console.log('----input:', res)
  396. },
  397. clear(res) {
  398. uni.showToast({
  399. title: 'clear事件,清除值为:' + res.value,
  400. icon: 'none'
  401. })
  402. },
  403. blur(res) {
  404. uni.showToast({
  405. title: 'blur事件,输入值为:' + res.value,
  406. icon: 'none'
  407. })
  408. },
  409. focus(e) {
  410. uni.showToast({
  411. title: 'focus事件,输出值为:' + e.value,
  412. icon: 'none'
  413. })
  414. },
  415. cancel(res) {
  416. uni.showToast({
  417. title: '点击取消,输入值为:' + res.value,
  418. icon: 'none'
  419. })
  420. }
  421. }
  422. }
  423. </script>
  424. <style lang="scss" scoped>
  425. .content1 {
  426. margin: 50rpx 25rpx 14rpx 25rpx;
  427. .search {
  428. width: 100%;
  429. .left {
  430. background: #F0F0F0;
  431. border-radius: 38rpx;
  432. padding: 18rpx;
  433. width: 100%;
  434. position: relative;
  435. }
  436. .search-val {
  437. color: #B3B3B3;
  438. }
  439. .search-del {
  440. position: absolute;
  441. right: 10px;
  442. }
  443. }
  444. .hy-search-img {
  445. width: 38rpx;
  446. height: auto;
  447. margin-left: 40rpx;
  448. }
  449. .search-img {
  450. width: 38rpx;
  451. margin-right: 40rpx;
  452. height: auto;
  453. }
  454. .right {
  455. /deep/.u-badge {
  456. position: absolute;
  457. top: 0;
  458. right: -10rpx;
  459. }
  460. }
  461. }
  462. .line {
  463. width: 8rpx;
  464. height: 34rpx;
  465. background: #112253;
  466. border-radius: 3px;
  467. margin: 20rpx;
  468. }
  469. .title {
  470. margin: 20rpx 0;
  471. }
  472. .text-title {
  473. font-size: 32rpx;
  474. font-weight: bold;
  475. color: #1A1A1A;
  476. }
  477. .row-tiem {
  478. // background: #fff;
  479. padding: 24rpx;
  480. // margin: 0 34rpx;
  481. align-items: unset;
  482. .img {
  483. width: 122rpx;
  484. height: 122rpx;
  485. border-radius: 10px;
  486. margin-right: 30rpx;
  487. }
  488. .right {
  489. display: flex;
  490. flex-direction: column;
  491. justify-content: space-evenly;
  492. .top {
  493. font-size: 32rpx;
  494. color: #1A1A1A;
  495. font-family: PingFang SC;
  496. font-weight: bold;
  497. }
  498. .bottom {
  499. margin-top: 10rpx;
  500. .text {
  501. background: #FAFAFA;
  502. border-radius: 10rpx;
  503. font-size: 26rpx;
  504. font-weight: 700;
  505. color: #666666;
  506. padding: 10rpx 20rpx;
  507. margin: 0px 10rpx 10rpx 0;
  508. }
  509. }
  510. }
  511. }
  512. .add {
  513. width: 84rpx;
  514. height: auto;
  515. position: fixed;
  516. bottom: 26rpx;
  517. right: 26rpx;
  518. height: auto;
  519. z-index: 999;
  520. }
  521. .wd-list,
  522. .tj-list {
  523. border-radius: 20rpx;
  524. background: #fff;
  525. margin: 0 34rpx;
  526. }
  527. .slot-content {
  528. width: 100%;
  529. }
  530. .auth-btncard {
  531. display: flex !important;
  532. justify-content: space-between !important;
  533. .btn-unok {
  534. width: 40%;
  535. }
  536. .btn-ok {
  537. width: 40%;
  538. }
  539. }
  540. .auth-card {
  541. text-align: center;
  542. .avatar-img {
  543. width: 250rpx;
  544. }
  545. .title {
  546. font-size: 20rpx;
  547. }
  548. .content {
  549. font-size: 32rpx;
  550. font-weight: bold;
  551. color: #1A1A1A;
  552. margin-bottom: 30rpx;
  553. }
  554. }
  555. .avatar-wrapper {
  556. color: #333 !important;
  557. border: none !important;
  558. border-radius: 0 !important;
  559. background-color: transparent !important;
  560. padding: 0;
  561. }
  562. .avatar-wrapper::after {
  563. border: none !important;
  564. }
  565. .avatar {
  566. width: 100rpx;
  567. height: 100rpx;
  568. overflow: hidden;
  569. border-radius: 100%;
  570. }
  571. /deep/.u-popup__content {
  572. border-radius: 20rpx !important;
  573. }
  574. </style>