list.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. <template>
  2. <view class="page page--divider">
  3. <headerline shownav=true isback="true" @tapnav="tapnav" :navstyle="navstyle" :navitem="navitem"
  4. :navselect="navselect" :statusbarheight='statusBarHeight' :menuitem="menuitem" @tapmenu="tapmenu"
  5. :rightmenu=false></headerline>
  6. <view id="grouplist" class="grouplist">
  7. <block v-for="(m,index) in groupData" :key='index'>
  8. <li v-if="(navselect==0 && m.createid==userid) || (navselect==1 && m.createid!=userid) "
  9. @tap="gochat(m)">
  10. <div class="avatar">
  11. <image :src="imgshow(m.avatar)"></image>
  12. </div>
  13. <div class="info">
  14. <div class="title">{{m.name}}</div>
  15. <div>
  16. <uni-icons type='person' style="font-size: 16px;font-weight: 700;"></uni-icons>
  17. {{m.people_count}}/{{m.people_max}}人
  18. </div>
  19. <div class="tag">{{m.tags}}</div>
  20. </div>
  21. </li>
  22. </block>
  23. </view>
  24. <view class="loading" v-if="loading">
  25. <view class="spinner">
  26. <view class="rect1"></view>
  27. <view class="rect2"></view>
  28. <view class="rect3"></view>
  29. <view class="rect4"></view>
  30. <view class="rect5"></view>
  31. </view>
  32. </view>
  33. <tabbar></tabbar>
  34. </view>
  35. </template>
  36. <script>
  37. import api from "../../library/index.js"
  38. import headerline from '../../components/header.vue'
  39. import http from "../../library/http.js"
  40. import uniIcons from '../../components/uni-icons/uni-icons.vue'
  41. import tabbar from '../../components/tabbar.vue'
  42. var statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
  43. export default {
  44. components: {
  45. uniIcons,
  46. headerline,
  47. tabbar
  48. },
  49. data() {
  50. return {
  51. statusBarHeight: statusBarHeight + 'px',
  52. newfriendNotify: false,
  53. showMenu: false,
  54. initializing: true,
  55. groupData: uni.getStorageSync(uni.getStorageSync('access_token') + '_groups'),
  56. navitem: ['我创建的群', '我加入的群'],
  57. navselect: 0,
  58. navstyle: "width:50%;left:25%",
  59. userid: uni.getStorageSync('access_token'),
  60. loading: true,
  61. user: uni.getStorageSync('userInfo'),
  62. menuitem: [
  63. ]
  64. }
  65. },
  66. methods: {
  67. tapnav(num) {
  68. this.navselect = num;
  69. },
  70. paramClick(e) {
  71. let page, params;
  72. if (e.type === 'friend') {
  73. const {
  74. id,
  75. nickname,
  76. avatar
  77. } = e;
  78. params = {
  79. id,
  80. nickname,
  81. avatar
  82. };
  83. page = 'friend.detail';
  84. } else if (e.type === 'room') {
  85. page = 'group.chat';
  86. params = e
  87. }
  88. this.$jump(page, params);
  89. },
  90. getMyGroup() {
  91. let data = {
  92. userid: this.userid
  93. }
  94. this.loading = true;
  95. api.getMyGroup(data).then(re => {
  96. uni.setStorageSync(this.userid + '_groups', re.data)
  97. for (let i in re.data) {
  98. re.data[i].type = 'room'
  99. }
  100. this.groupData = re.data
  101. this.loading = false;
  102. });
  103. },
  104. imgshow(image_url) {
  105. if (image_url.indexOf('http') <= -1) image_url = config.imgUri + image_url;
  106. return this.image_cache(image_url)
  107. },
  108. gochat(m) {
  109. this.$jump('group.chat', {
  110. id: m.id,
  111. nickname: m.name
  112. });
  113. },
  114. tapmenu(num) {
  115. if (this.$action.loginTips('未登录用户,无法完成此操作', '/pages/game/index') == false) return false;
  116. if (this.$action.check_userlock() == false) return false;
  117. if (num == 0) {
  118. if (this.user.isvip == 1) {
  119. if (this.isadd == true) {
  120. uni.showModal({
  121. title: '提示',
  122. content: this.addtips,
  123. showCancel: true,
  124. cancelText: '取消',
  125. confirmText: '继续发布',
  126. success: res => {
  127. if (res.confirm) {
  128. this.$jump('plan.add', {
  129. gameid: this.gameid
  130. });
  131. }
  132. }
  133. });
  134. } else {
  135. uni.showToast({
  136. title: this.addtips,
  137. icon: 'none'
  138. })
  139. }
  140. } else {
  141. if (this.user.mobile == '') {
  142. uni.showModal({
  143. title: '提示',
  144. content: "您还没有绑定手机号,不能申请计划员",
  145. showCancel: true,
  146. cancelText: '关闭',
  147. confirmText: '绑定手机号',
  148. success: res => {
  149. if (res.confirm) {
  150. uni.navigateTo({
  151. url: "/pages/mine/mobile"
  152. })
  153. }
  154. }
  155. });
  156. } else {
  157. this.$jump('plan.apply');
  158. }
  159. }
  160. } else if (num == 1) {
  161. if (this.user.nickname == '') {
  162. this.$action.profileTips('未设置昵称,不能创建群', '/pages/group/create');
  163. return false;
  164. } else
  165. this.jump('group.create');
  166. } else if (num == 2) {
  167. this.jump('mine.recharge')
  168. } else if (num == 3) {
  169. this.jump('mine.cash')
  170. } else if (num == 4) {
  171. return uni.scanCode({
  172. success(res) {
  173. scode.getScode(res)
  174. },
  175. fail(e) {
  176. console.log(JSON.stringify(e));
  177. console.log('扫码失败')
  178. }
  179. });
  180. }
  181. },
  182. jump(url) {
  183. this.$jump(url);
  184. },
  185. setrightmenu() {
  186. if (this.user.id > 0) {
  187. this.getaddtips();
  188. }
  189. var menuitem = [];
  190. if (this.user.isvip == 1) {
  191. menuitem.push({
  192. 'title': '发布计划',
  193. 'icon': 'plusempty'
  194. });
  195. } else {
  196. menuitem.push({
  197. 'title': '申请计划员',
  198. 'icon': 'plusempty'
  199. });
  200. }
  201. menuitem.push({
  202. 'title': '创建群组',
  203. 'icon': 'personadd'
  204. });
  205. menuitem.push({
  206. 'title': '我要充值',
  207. 'icon': 'plus'
  208. });
  209. menuitem.push({
  210. 'title': '我要提现',
  211. 'icon': 'minus'
  212. });
  213. // #ifdef APP-PLUS
  214. menuitem.push({
  215. 'title': '扫一扫',
  216. 'icon': 'scan'
  217. });
  218. // #endif
  219. this.menuitem = menuitem;
  220. },
  221. getaddtips() {
  222. http.setWait(false).post('plan.php?act=addplantips', {
  223. from: 'app',
  224. userid: this.user.id
  225. }).then(res => {
  226. if (res.code == 200) {
  227. this.isadd = res.isadd;
  228. this.addtips = res.data;
  229. }
  230. });
  231. },
  232. },
  233. onShow() {
  234. this.getMyGroup();
  235. this.setrightmenu();
  236. },
  237. onLoad(opts) {
  238. if (opts.method > 0) this.navselect = opts.method;
  239. }
  240. }
  241. </script>
  242. <style lang="scss" scoped>
  243. @import "@/static/css/group.css";
  244. .item {
  245. height: 100upx;
  246. border-bottom: 1px solid #F0F0F0;
  247. overflow: hidden;
  248. padding: $uni-spacing-col-lg 30upx;
  249. display: flex;
  250. flex-direction: row;
  251. justify-content: flex-start;
  252. align-items: center;
  253. background-color: #ffffff;
  254. border-radius: 20upx;
  255. }
  256. .leftImg {
  257. width: 100upx;
  258. height: 100upx;
  259. margin-right: $uni-spacing-row-base;
  260. border-radius: $uni-border-radius-base;
  261. display: flex;
  262. flex-flow: wrap;
  263. justify-content: center;
  264. background-color: #eee;
  265. align-items: center;
  266. &:not(image) {
  267. padding: 1upx;
  268. }
  269. view,
  270. image {
  271. width: (76upx-2upx*4)/3;
  272. height: (76upx-2upx*4)/3;
  273. margin: 1upx;
  274. }
  275. }
  276. .rightContent {
  277. flex: 1;
  278. }
  279. .rightContent,
  280. .topCont {
  281. overflow: hidden;
  282. line-height: 1.25;
  283. }
  284. .topCont {
  285. display: flex;
  286. flex-direction: row;
  287. justify-content: space-between;
  288. align-items: center;
  289. }
  290. .userName {
  291. color: $uni-text-color;
  292. font-size: 38upx;
  293. }
  294. .time {
  295. color: #999999;
  296. font-size: 30upx;
  297. }
  298. .bottomCont {
  299. width: 100%;
  300. font-size: 24upx;
  301. color: #999999;
  302. display: flex;
  303. align-items: center;
  304. justify-content: space-between;
  305. }
  306. .content {
  307. font-size: 28upx;
  308. overflow: hidden;
  309. text-overflow: ellipsis;
  310. white-space: nowrap;
  311. }
  312. .badge {
  313. background-color: red;
  314. color: #fff;
  315. border-radius: 40upx;
  316. line-height: 40upx;
  317. width: 40upx;
  318. height: 40upx;
  319. font-size: 24upx;
  320. text-align: center;
  321. flex-shrink: 0;
  322. }
  323. .loading {
  324. //loading动画
  325. display: flex;
  326. justify-content: center;
  327. @keyframes stretchdelay {
  328. 0%,
  329. 40%,
  330. 100% {
  331. transform: scaleY(0.6);
  332. }
  333. 20% {
  334. transform: scaleY(1.0);
  335. }
  336. }
  337. .spinner {
  338. margin: 20upx 0;
  339. width: 60upx;
  340. height: 25px;
  341. display: flex;
  342. align-items: center;
  343. justify-content: space-between;
  344. view {
  345. background-color: #ff9800;
  346. height: 25px;
  347. width: 3px;
  348. border-radius: 3px;
  349. animation: stretchdelay 1.2s infinite ease-in-out;
  350. }
  351. .rect2 {
  352. animation-delay: -1.1s;
  353. }
  354. .rect3 {
  355. animation-delay: -1.0s;
  356. }
  357. .rect4 {
  358. animation-delay: -0.9s;
  359. }
  360. .rect5 {
  361. animation-delay: -0.8s;
  362. }
  363. }
  364. }
  365. </style>