groupManage.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <view>
  3. <view class="tits ddflex">
  4. <view class="flex">全部分组
  5. <!-- <text>(长按支持编辑)</text> -->
  6. </view>
  7. <navigator url="/card/addGroup/addGroup?isAdd=true" hover-class="none" class="create">+ 新建分组</navigator>
  8. </view>
  9. <view class="list" v-if="manageLabelList&&manageLabelList.length>0">
  10. <view
  11. :class="'li ddflex' + (pickerUserIndex == index ? ' long' : '')"
  12. @longpress="onLongPress"
  13. class="li ddflex"
  14. :data-index="index"
  15. v-for="(item, index) in manageLabelList"
  16. :key="index"
  17. @tap="listTap(item)"
  18. >
  19. <view class="flex tover">{{ item.groupName }}</view>
  20. <!-- <text class="nums">{{ item.person }}</text> -->
  21. <image src="../../static/images/rico1.png" class="rico"></image>
  22. </view>
  23. </view>
  24. <view class="nodata" v-else>
  25. <!-- <image src="../../static/images/empty_dd.png"></image> -->
  26. <view>暂无分组~</view>
  27. </view>
  28. <view class="shade" v-show="showShade" @tap="hidePop">
  29. <view class="pop" :style="popStyle" :class="{ show: showPop }">
  30. <view v-for="(item, index) in popButton" :key="index" @tap="pickerMenu" :data-index="index">{{ item }}</view>
  31. </view>
  32. </view>
  33. <!-- <view class="mask" @click="closePop()" v-if="isShow"></view> -->
  34. </view>
  35. </template>
  36. <script>
  37. const app = getApp();
  38. const req = require('../../utils/request.js');
  39. const api = require('../../utils/api.js');
  40. export default {
  41. data() {
  42. return {
  43. /* 窗口尺寸 */
  44. winSize: {},
  45. /* 显示遮罩 */
  46. showShade: false,
  47. /* 显示操作弹窗 */
  48. showPop: false,
  49. /* 弹窗定位样式 */
  50. popStyle: '',
  51. /* 选择的用户下标 */
  52. pickerUserIndex: -1,
  53. /* 弹窗按钮列表 */
  54. popButton: ['编辑分组', '删除分组'],
  55. manageLabelList: '',
  56. longItemId: '',
  57. isFrist: true,
  58. cardId:null
  59. };
  60. },
  61. onLoad(options) {
  62. this.getWindowSize();
  63. // #ifdef H5
  64. document.onLong = function(e) {
  65. var e = e || window.event;
  66. e.preventDefault();
  67. };
  68. // #endif
  69. if(options.cardId){
  70. this.cardId = options.cardId
  71. uni.setNavigationBarTitle({
  72. title:'选择名片夹'
  73. })
  74. }
  75. },
  76. onShow() {
  77. this.getManageLabelList();
  78. },
  79. methods: {
  80. jumpUrl(url) {
  81. uni.navigateTo({
  82. url: url
  83. });
  84. },
  85. edit() {
  86. this.jumpUrl('/customer/addGroup/addGroup?groupId=' + this.manageLabelList[this.longItemId].id + '&title=' + this.manageLabelList[this.longItemId].groupName);
  87. },
  88. del() {
  89. this.deleteLabel();
  90. },
  91. deleteLabel() {
  92. console.log('deleteLabel数据>>>>>>>>>');
  93. req.msgConfirm('确定要删除该分组吗?', success => {
  94. this.deleteLabelRequest();
  95. });
  96. },
  97. deleteLabelRequest() {
  98. req.postRequest(
  99. '/api/v3/visiting/card/group/delete',
  100. { id: this.manageLabelList[this.longItemId].id },
  101. json => {
  102. this.getManageLabelList();
  103. },
  104. true
  105. );
  106. },
  107. getManageLabelList() {
  108. req.getRequest(
  109. '/api/v3/visiting/card/group/list',
  110. {},
  111. json => {
  112. this.manageLabelList = json;
  113. this.isFrist = false;
  114. },
  115. this.isFrist
  116. );
  117. },
  118. /* 获取窗口尺寸 */
  119. getWindowSize() {
  120. uni.getSystemInfo({
  121. success: res => {
  122. this.winSize = {
  123. witdh: res.windowWidth,
  124. height: res.windowHeight
  125. };
  126. }
  127. });
  128. },
  129. /* 列表触摸事件 */
  130. listTap(item) {
  131. if(this.cardId){
  132. this.$showModal({
  133. title: '提示',
  134. content: '确定要移动到该分组吗?'
  135. })
  136. .then(res => {
  137. let pages = getCurrentPages();
  138. var prevPage = pages[pages.length - 2];
  139. if (prevPage) {
  140. prevPage.$vm.changeGroup(this.cardId,item.id);
  141. uni.navigateBack()
  142. }
  143. })
  144. .catch(err => {
  145. });
  146. }else{
  147. /* 因弹出遮罩问题,所以需要在遮罩弹出的情况下阻止列表事件的触发 */
  148. if (this.showShade) {
  149. return;
  150. }
  151. this.jumpUrl('/card/addGroup/addGroup?groupId=' + item.id + '&title=' + item.groupName);
  152. // this.jumpUrl('/customer/labelCustomer/labelCustomer?groupId=' + item.id + '&title=' + item.title);
  153. }
  154. },
  155. /* 长按监听 */
  156. onLongPress(e) {
  157. // let [touches, style, index] = [e.touches[0], '', e.currentTarget.dataset.index];
  158. // /* 因 非H5端不兼容 style 属性绑定 Object ,所以拼接字符 */
  159. // if (touches.clientY > this.winSize.height / 2) {
  160. // style = `bottom:${this.winSize.height - touches.clientY}px;`;
  161. // } else {
  162. // style = `top:${touches.clientY}px;`;
  163. // }
  164. // if (touches.clientX > this.winSize.witdh / 2) {
  165. // style += `right:${this.winSize.witdh - touches.clientX}px`;
  166. // } else {
  167. // style += `left:${touches.clientX}px`;
  168. // }
  169. // this.popStyle = style;
  170. // this.pickerUserIndex = Number(index);
  171. // this.longItemId = Number(index);
  172. // this.showShade = true;
  173. // this.$nextTick(() => {
  174. // setTimeout(() => {
  175. // this.showPop = true;
  176. // }, 10);
  177. // });
  178. },
  179. /* 隐藏弹窗 */
  180. hidePop() {
  181. this.showPop = false;
  182. this.pickerUserIndex = -1;
  183. setTimeout(() => {
  184. this.showShade = false;
  185. }, 250);
  186. },
  187. /* 选择菜单 */
  188. pickerMenu(e) {
  189. let index = Number(e.currentTarget.dataset.index);
  190. if (index == 0) {
  191. //编辑
  192. this.edit();
  193. } else if (index == 1) {
  194. //删除
  195. this.del();
  196. }
  197. /*
  198. 因为隐藏弹窗方法中会将当前选择的用户下标还原为-1,
  199. 如果行的菜单方法存在异步情况,请在隐藏之前将该值保存,或通过参数传入异步函数中
  200. */
  201. this.hidePop();
  202. }
  203. }
  204. };
  205. </script>
  206. <style>
  207. @import './groupManage.css';
  208. </style>