circle.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  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 v-if='hidden!="隐藏"' 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. hidden:'',
  189. searchVal: '',
  190. circleList: [],
  191. userInfo: {},
  192. canReset: false,
  193. cardList: [],
  194. circleList1: [],
  195. downOption: {
  196. auto: false,
  197. textColor: '#bbb'
  198. },
  199. upOption: {
  200. page: {
  201. size: 10 // 每页数据的数量,默认10
  202. },
  203. auto: false,
  204. noMoreSize: 1,
  205. textNoMore: '没有更多了~',
  206. textColor: '#bbb'
  207. }
  208. };
  209. },
  210. onLoad() {
  211. that = this
  212. if (uni.getStorageSync("userInfo").phone) {
  213. this.userInfo = uni.getStorageSync("userInfo")
  214. this.$nextTick(function() {
  215. that.mescroll.resetUpScroll()
  216. });
  217. this.$request.baseRequest('admin.unimall.cardExchangeInfo', 'list', {
  218. receiveId: this.userInfo.id,
  219. status: 1
  220. }, failres => {
  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. this.$request.baseRequest('admin.dictData', 'list', {
  236. dictType:'circle_friends'
  237. }, failres => {
  238. }).then( res => {
  239. console.log(res,11111)
  240. this.hidden=res.data.items[0].dictLabel
  241. })
  242. if (uni.getStorageSync("userInfo").phone) {
  243. this.userInfo = uni.getStorageSync("userInfo")
  244. this.$request.baseRequest('admin.unimall.cardExchangeInfo', 'list', {
  245. receiveId: this.userInfo.id,
  246. status: 1
  247. }, failres => {
  248. uni.showToast({
  249. icon: "none",
  250. title: failres.errmsg,
  251. duration: 3000
  252. });
  253. }).then(res => {
  254. this.searchVal = uni.getStorageSync("cirlce_search_val") ? uni.getStorageSync(
  255. "cirlce_search_val") : ''
  256. if (this.searchVal) this.mescroll.resetUpScroll();
  257. })
  258. } else {
  259. this.showAuthorizePhone = true
  260. }
  261. },
  262. methods: {
  263. //获取昵称输入内容
  264. userNameInput(e) {
  265. this.userInfo.nickname = e.detail.value
  266. },
  267. async onChooseAvatar(e) {
  268. this.$set(this.userInfo, "head", await this.toBase64(e.detail.avatarUrl))
  269. },
  270. toBase64(url) {
  271. return new Promise(resolve => {
  272. pathToBase64(url).then(path => {
  273. resolve(path);
  274. }).catch(error => {
  275. console.log(error)
  276. })
  277. })
  278. },
  279. async authUser(type) {
  280. //同步信息,没有头像和昵称自动生成
  281. this.userInfo = await this.$request.syncInfo(this.userInfo)
  282. if(this.userInfo.openId) {
  283. uni.setStorageSync("userInfo", that.userInfo)
  284. that.showAuthorizeUser = false
  285. that.mescroll.resetUpScroll()
  286. }
  287. },
  288. downCallback() {
  289. if (uni.getStorageSync("userInfo").phone) {
  290. this.mescroll.resetUpScroll()
  291. } else {
  292. this.mescroll.endBySize(0, 0)
  293. this.showAuthorizePhone = true
  294. }
  295. },
  296. async getPhoneNumber(e) {
  297. that.userInfo = await this.$request.wxlogin()
  298. that.userInfo.phone = await this.$request.getPhone(e, that.userInfo)
  299. this.showAuthorizePhone = false
  300. this.showAuthorizeUser = true
  301. },
  302. delSearchVal() {
  303. this.searchVal = ""
  304. uni.removeStorageSync('cirlce_search_val')
  305. this.mescroll.resetUpScroll()
  306. },
  307. toChangeCard() {
  308. if (this.userInfo.phone) {
  309. uni.navigateTo({
  310. url: "/pageA/circle/changeCard"
  311. })
  312. } else {
  313. this.showAuthorizePhone = true
  314. }
  315. },
  316. toCreateCircle() {
  317. if (this.userInfo.phone) {
  318. uni.navigateTo({
  319. url: "/pageA/circle/createCirclce"
  320. })
  321. } else {
  322. this.showAuthorizePhone = true
  323. }
  324. },
  325. micOpen: function() {
  326. this.$refs.asr.show();
  327. },
  328. search() {
  329. if (this.userInfo.phone) {
  330. uni.navigateTo({
  331. url: "/pageA/circle/search"
  332. })
  333. } else {
  334. this.showAuthorizePhone = true
  335. }
  336. },
  337. toDetail(val) {
  338. uni.navigateTo({
  339. url: "/pageA/circle/detail?val=" + val
  340. })
  341. },
  342. upCallback(page) {
  343. uni.showLoading({
  344. title: '数据加载中'
  345. })
  346. let _data = {
  347. commonId: this.userInfo.id,
  348. page: page.num,
  349. limit: page.size,
  350. status: 1
  351. }
  352. if (this.searchVal) {
  353. _data.circleName = this.searchVal
  354. }
  355. this.$request.baseRequest('admin.unimall.circleManagementInfo', 'list', _data, failres => {
  356. console.log('res+++++', failres.errmsg)
  357. uni.showToast({
  358. icon: "none",
  359. title: failres.errmsg,
  360. duration: 3000
  361. });
  362. uni.hideLoading()
  363. }).then(res => {
  364. uni.hideLoading()
  365. console.log(11)
  366. let curPageData = res.data.items;
  367. let totalPage = res.data.total;
  368. let curPageLen = curPageData.length;
  369. this.mescroll.endByPage(curPageLen, totalPage);
  370. console.log(res.data)
  371. // this.makeData(res.data)
  372. //追加新数据
  373. for (let i = 0; i < this.circleList.length; i++) {
  374. if (this.circleList[i].circleLabel) {
  375. if (this.circleList[i].circleLabel.split(',').length >= 3) {
  376. var arr = this.circleList[i].circleLabel.split(',')
  377. console.log(arr)
  378. this.circleList[i].circleLabelArray = arr.filter((item, index) => {
  379. return index <= 2
  380. })
  381. } else {
  382. this.circleList[i].circleLabelArray = this.circleList[i].circleLabel.split(',')
  383. }
  384. }
  385. }
  386. if (page.num == 1) this.circleList1 = [];
  387. this.circleList = []; //如果是第一页需手动置空列表
  388. var tjarr = curPageData.filter((item) => {
  389. return item.addedFlag == 0
  390. })
  391. var wdarr = curPageData.filter((item) => {
  392. return item.addedFlag == 1
  393. })
  394. this.circleList1 = this.circleList1.concat(wdarr);
  395. this.circleList = this.circleList.concat(tjarr);
  396. })
  397. },
  398. input(res) {
  399. console.log('----input:', res)
  400. },
  401. clear(res) {
  402. uni.showToast({
  403. title: 'clear事件,清除值为:' + res.value,
  404. icon: 'none'
  405. })
  406. },
  407. blur(res) {
  408. uni.showToast({
  409. title: 'blur事件,输入值为:' + res.value,
  410. icon: 'none'
  411. })
  412. },
  413. focus(e) {
  414. uni.showToast({
  415. title: 'focus事件,输出值为:' + e.value,
  416. icon: 'none'
  417. })
  418. },
  419. cancel(res) {
  420. uni.showToast({
  421. title: '点击取消,输入值为:' + res.value,
  422. icon: 'none'
  423. })
  424. }
  425. }
  426. }
  427. </script>
  428. <style lang="scss" scoped>
  429. .content1 {
  430. margin: 50rpx 25rpx 14rpx 25rpx;
  431. .search {
  432. width: 100%;
  433. .left {
  434. background: #F0F0F0;
  435. border-radius: 38rpx;
  436. padding: 18rpx;
  437. width: 100%;
  438. position: relative;
  439. }
  440. .search-val {
  441. color: #B3B3B3;
  442. }
  443. .search-del {
  444. position: absolute;
  445. right: 10px;
  446. }
  447. }
  448. .hy-search-img {
  449. width: 38rpx;
  450. height: auto;
  451. margin-left: 40rpx;
  452. }
  453. .search-img {
  454. width: 38rpx;
  455. margin-right: 40rpx;
  456. height: auto;
  457. }
  458. .right {
  459. /deep/.u-badge {
  460. position: absolute;
  461. top: 0;
  462. right: -10rpx;
  463. }
  464. }
  465. }
  466. .line {
  467. width: 8rpx;
  468. height: 34rpx;
  469. background: #112253;
  470. border-radius: 3px;
  471. margin: 20rpx;
  472. }
  473. .title {
  474. margin: 20rpx 0;
  475. }
  476. .text-title {
  477. font-size: 32rpx;
  478. font-weight: bold;
  479. color: #1A1A1A;
  480. }
  481. .row-tiem {
  482. // background: #fff;
  483. padding: 24rpx;
  484. // margin: 0 34rpx;
  485. align-items: unset;
  486. .img {
  487. width: 122rpx;
  488. height: 122rpx;
  489. border-radius: 10px;
  490. margin-right: 30rpx;
  491. }
  492. .right {
  493. display: flex;
  494. flex-direction: column;
  495. justify-content: space-evenly;
  496. .top {
  497. font-size: 32rpx;
  498. color: #1A1A1A;
  499. font-family: PingFang SC;
  500. font-weight: bold;
  501. }
  502. .bottom {
  503. margin-top: 10rpx;
  504. .text {
  505. background: #FAFAFA;
  506. border-radius: 10rpx;
  507. font-size: 26rpx;
  508. font-weight: 700;
  509. color: #666666;
  510. padding: 10rpx 20rpx;
  511. margin: 0px 10rpx 10rpx 0;
  512. }
  513. }
  514. }
  515. }
  516. .add {
  517. width: 84rpx;
  518. height: auto;
  519. position: fixed;
  520. bottom: 26rpx;
  521. right: 26rpx;
  522. height: auto;
  523. z-index: 999;
  524. }
  525. .wd-list,
  526. .tj-list {
  527. border-radius: 20rpx;
  528. background: #fff;
  529. margin: 0 34rpx;
  530. }
  531. .slot-content {
  532. width: 100%;
  533. }
  534. .auth-btncard {
  535. display: flex !important;
  536. justify-content: space-between !important;
  537. .btn-unok {
  538. width: 40%;
  539. }
  540. .btn-ok {
  541. width: 40%;
  542. }
  543. }
  544. .auth-card {
  545. text-align: center;
  546. .avatar-img {
  547. width: 250rpx;
  548. }
  549. .title {
  550. font-size: 20rpx;
  551. }
  552. .content {
  553. font-size: 32rpx;
  554. font-weight: bold;
  555. color: #1A1A1A;
  556. margin-bottom: 30rpx;
  557. }
  558. }
  559. .avatar-wrapper {
  560. color: #333 !important;
  561. border: none !important;
  562. border-radius: 0 !important;
  563. background-color: transparent !important;
  564. padding: 0;
  565. }
  566. .avatar-wrapper::after {
  567. border: none !important;
  568. }
  569. .avatar {
  570. width: 100rpx;
  571. height: 100rpx;
  572. overflow: hidden;
  573. border-radius: 100%;
  574. }
  575. /deep/.u-popup__content {
  576. border-radius: 20rpx !important;
  577. }
  578. </style>