group_admin.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <view class="page">
  3. <scroll-view class="scrollList" scroll-y :scroll-into-view="scrollViewId" :style="{height:winHeight + 'px'}">
  4. <view class="uni-list">
  5. <block v-for="(list, key) in list_data" :key="key">
  6. <view class="uni-list-cell-divider" :id="list.letter">
  7. {{list.letter}}
  8. </view>
  9. <view class="uni-list-cell"
  10. hover-class="none"
  11. v-for="(item,index) of list.data"
  12. :class="list.data.length -1 == index ? 'uni-list-cell-last' : ''"
  13. :key="isKey(key,index)"
  14. >
  15. <checkbox-group @change="change(item.user_id + '')">
  16. <label class="uni-list-cell uni-list-cell-pd">
  17. <view>
  18. <checkbox color="#02b300"
  19. :checked="item.is_admin"
  20. :value="item.user_id + ''"
  21. />
  22. </view>
  23. <view class="uni-media-list">
  24. <view class="uni-media-list-logo">
  25. <image :src="staticPhoto + item.photo" :lazy-load="true"/>
  26. </view>
  27. <view class="uni-media-list-body">
  28. <view class="uni-list-cell-navigate">{{item.name}}</view>
  29. </view>
  30. </view>
  31. </label>
  32. </checkbox-group>
  33. </view>
  34. </block>
  35. </view>
  36. </scroll-view>
  37. <view class="uni-indexed-list-bar" :class="touchmove ? 'active' : ''" @touchstart="touchStart" @touchmove="touchMove"
  38. @touchend="touchEnd" @touchcancel="touchCancel" :style="{height:winHeight + 'px'}">
  39. <text v-for="(list,key) in list_data" :key="key" class="uni-indexed-list-text" :class="touchmoveIndex == key ? 'active' : ''"
  40. :style="{height:itemHeight + 'px',lineHeight:itemHeight + 'px'}">
  41. {{list.letter}}
  42. </text>
  43. </view>
  44. <view class="uni-indexed-list-alert" v-if="touchmove">
  45. {{list_data[touchmoveIndex].letter}}
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import uniIcon from '../../components/uni-ui/uni-icon/uni-icon.vue';
  51. import uniList from '../../components/uni-ui/uni-list/uni-list.vue';
  52. import uniListItem from '../../components/uni-ui/uni-list-item/uni-list-item.vue';
  53. import _get from '../../common/_get';
  54. import _hook from '../../common/_hook';
  55. import _data from '../../common/_data';
  56. export default {
  57. components: {
  58. uniIcon,
  59. uniList,
  60. uniListItem,
  61. },
  62. data() {
  63. return {
  64. list_data: [],
  65. title: 'grid',
  66. touchmove: false,
  67. touchmoveIndex: -1,
  68. itemHeight: 0,
  69. winHeight: 0,
  70. scrollViewId: "A",
  71. titleHeight: 0,
  72. list_id: 0,
  73. add_user_ids: [],
  74. type: 0,
  75. }
  76. },
  77. onShow(){
  78. _hook.routeTabBarHook();
  79. },
  80. onLoad(option) {
  81. let _this = this;
  82. _this.list_id = option.list_id;
  83. _this.type = option.type;
  84. if(_this.type == 2){
  85. uni.setNavigationBarTitle({
  86. title: '禁言设置',
  87. });
  88. }
  89. _this.$httpSend({
  90. path: '/im/message/getGroupAdmin',
  91. data: { list_id: this.list_id,type: _this.type, },
  92. success(data) {
  93. _this.list_data = data.list;
  94. _this.add_user_ids = data.user_ids;
  95. }
  96. });
  97. let winHeight = uni.getSystemInfoSync().windowHeight;
  98. _this.itemHeight = winHeight / 26;
  99. _this.winHeight = winHeight;
  100. },
  101. computed: {
  102. staticPhoto(){
  103. return _data.staticPhoto();
  104. }
  105. },
  106. methods: {
  107. change(user_id){
  108. if(user_id){
  109. let i = this.add_user_ids.indexOf(user_id);
  110. if(i > -1){
  111. this.add_user_ids.splice(i,1);
  112. }else{
  113. this.add_user_ids.push(user_id);
  114. }
  115. }
  116. },
  117. isKey(key,index){
  118. return key + '' + index;
  119. },
  120. touchStart(e) {
  121. this.touchmove = true;
  122. let pageY = e.touches[0].pageY;
  123. let index = Math.floor((pageY - this.titleHeight) / this.itemHeight);
  124. let item = this.list_data[index];
  125. if (item) {
  126. this.scrollViewId = item.letter;
  127. this.touchmoveIndex = index;
  128. }
  129. },
  130. touchMove(e) {
  131. let pageY = e.touches[0].pageY;
  132. let index = Math.floor((pageY - this.titleHeight) / this.itemHeight);
  133. let item = this.list_data[index];
  134. if (item) {
  135. this.scrollViewId = item.letter;
  136. this.touchmoveIndex = index;
  137. }
  138. },
  139. touchEnd() {
  140. this.touchmove = false;
  141. //this.touchmoveIndex = -1;
  142. },
  143. touchCancel() {
  144. this.touchmove = false;
  145. //this.touchmoveIndex = -1;
  146. },
  147. },
  148. watch: {
  149. },
  150. onNavigationBarButtonTap(e) {
  151. let _this = this;
  152. _this.$httpSend({
  153. path: '/im/message/setGroupAdmin',
  154. data: { users: JSON.stringify(_this.add_user_ids),list_id: _this.list_id,type: _this.type, },
  155. success_action: true,
  156. success(res) {
  157. uni.showToast({
  158. title: res.msg,
  159. duration: 2000
  160. });
  161. setTimeout(() => {
  162. uni.redirectTo({
  163. url: '../chat/message/more?list_id=' + _this.list_id,
  164. });
  165. },2000);
  166. }
  167. });
  168. }
  169. }
  170. </script>
  171. <style>
  172. .page {
  173. display: flex;
  174. flex-direction:row;
  175. }
  176. .scrollList {
  177. flex: 1;
  178. height: 100vh;
  179. }
  180. .uni-indexed-list-bar {
  181. width: 40upx;
  182. height: 100vh;
  183. background-color: #e7e7e7;
  184. display: flex;
  185. flex-direction: column;
  186. }
  187. .uni-indexed-list-bar.active {
  188. /* background-color: rgb(200, 200, 200); */
  189. }
  190. .uni-indexed-list-text {
  191. font-size: 22upx;
  192. text-align: center;
  193. }
  194. .uni-indexed-list-bar.active .uni-indexed-list-text {
  195. color: #333;
  196. }
  197. .uni-indexed-list-text.active,
  198. .uni-indexed-list-bar.active .uni-indexed-list-text.active {
  199. color: #02b300;
  200. }
  201. .uni-indexed-list-alert {
  202. position: absolute;
  203. z-index: 20;
  204. width: 160upx;
  205. height: 160upx;
  206. left: 50%;
  207. top: 50%;
  208. margin-left: -80upx;
  209. margin-top: -80upx;
  210. border-radius: 80upx;
  211. text-align: center;
  212. line-height: 160upx;
  213. font-size: 70upx;
  214. color: #fff;
  215. background-color: rgba(0, 0, 0, 0.5);
  216. }
  217. .header {
  218. display: flex;
  219. flex-direction: row;
  220. padding: 10px 15px;
  221. align-items: center;
  222. }
  223. .input-view {
  224. display: flex;
  225. align-items: center;
  226. flex-direction: row;
  227. background-color: #e7e7e7;
  228. height: 30px;
  229. border-radius: 5px;
  230. padding: 0 10px;
  231. flex: 1;
  232. }
  233. .input {
  234. flex: 1;
  235. padding: 0 5px;
  236. height: 24px;
  237. line-height: 24px;
  238. font-size: 16px;
  239. }
  240. .uni-list-cell-navigate {
  241. padding: 0;
  242. }
  243. .uni-media-list-body {
  244. height: auto;
  245. }
  246. </style>