index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <view class="page_container">
  3. <custom-nav-bar title="谁可以看" :route="false" @leftClick="leftClick">
  4. <view class="nav_right_action" slot="more">
  5. <u-button
  6. type="primary"
  7. size="mini"
  8. text="完成"
  9. @click="transferData(false)"
  10. ></u-button>
  11. </view>
  12. </custom-nav-bar>
  13. <view class="settings_wrap">
  14. <setting-item title="公开" @click="permission = 0">
  15. <view class="left_icon" slot="icon">
  16. <image
  17. v-show="permission === 0"
  18. src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/moments_checked.png"
  19. />
  20. </view>
  21. <view class="left_desc" slot="left"> 所有人可见 </view>
  22. </setting-item>
  23. <!-- <setting-item title="同事和好友" @click="permission = 1">
  24. <view class="left_icon" slot="icon">
  25. <image v-show="permission === 1" src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/moments_checked.png" />
  26. </view>
  27. <view class="left_desc" slot="left">
  28. 所在组织同事和好友可见
  29. </view>
  30. </setting-item> -->
  31. <setting-item title="私密" @click="permission = 1">
  32. <view class="left_icon" slot="icon">
  33. <image
  34. v-show="permission === 1"
  35. src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/moments_checked.png"
  36. />
  37. </view>
  38. <view class="left_desc" slot="left"> 仅自己可见 </view>
  39. </setting-item>
  40. <setting-item title="部分可见" show-right @click="chooseMember()">
  41. <view class="left_icon" slot="icon">
  42. <image
  43. v-show="permission === 2"
  44. src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/moments_checked.png"
  45. />
  46. </view>
  47. <view class="left_desc" slot="left">
  48. <view> 选中的人可见 </view>
  49. <view v-show="permission === 2" class="">
  50. {{ choosedNameStr }}
  51. </view>
  52. </view>
  53. </setting-item>
  54. <setting-item title="不给谁看" show-right @click="chooseMember(false)">
  55. <view class="left_icon" slot="icon">
  56. <image
  57. v-show="permission === 3"
  58. src="https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/shop/image/moments_checked.png"
  59. />
  60. </view>
  61. <view class="left_desc" slot="left">
  62. <view> 选中的人不可见 </view>
  63. <view v-show="permission === 3" class="">
  64. {{ choosedNameStr }}
  65. </view>
  66. </view>
  67. </setting-item>
  68. </view>
  69. </view>
  70. </template>
  71. <script>
  72. import CustomNavBar from "../../../components/CustomNavBar/index.vue";
  73. import { ContactChooseTypes } from "../../../constant";
  74. import SettingItem from "../momentsRelease/SettingItem.vue";
  75. export default {
  76. components: {
  77. CustomNavBar,
  78. SettingItem,
  79. },
  80. data() {
  81. return {
  82. permission: null,
  83. choosedUserInfoList: [],
  84. choosedGroupInfoList: [],
  85. originData: {},
  86. watchFlag: false,
  87. updateFlag: false,
  88. };
  89. },
  90. computed: {
  91. choosedNameStr() {
  92. if (this.permission === 0) {
  93. return "公开";
  94. }
  95. if (this.permission === 1) {
  96. return "私密";
  97. }
  98. let str = "";
  99. this.choosedUserInfoList.map((user) => (str += `${user.nickname}、`));
  100. this.choosedGroupInfoList.map((group) => (str += `${group.groupName}、`));
  101. return str.slice(0, str.length - 1);
  102. },
  103. },
  104. watch: {
  105. permission(newVal) {
  106. if (this.watchFlag) {
  107. this.choosedUserInfoList = [];
  108. this.choosedGroupInfoList = [];
  109. this.updateFlag = true;
  110. } else {
  111. this.watchFlag = true;
  112. }
  113. },
  114. },
  115. onLoad(options) {
  116. const {
  117. permission,
  118. choosedUserInfoList,
  119. choosedGroupInfoList,
  120. choosedNameStr,
  121. } = options;
  122. this.permission = JSON.parse(permission);
  123. this.choosedUserInfoList = JSON.parse(choosedUserInfoList);
  124. this.choosedGroupInfoList = JSON.parse(choosedGroupInfoList);
  125. this.originData = {
  126. choosedUserInfoList: this.choosedUserInfoList,
  127. choosedGroupInfoList: this.choosedGroupInfoList,
  128. permission: this.permission,
  129. choosedNameStr,
  130. };
  131. },
  132. methods: {
  133. chooseMember(canSee = true) {
  134. this.permission = canSee ? 2 : 3;
  135. this.updateFlag = true;
  136. uni.$u.route("/pages/common/contactChoose/index", {
  137. type: ContactChooseTypes.GetListWithGroup,
  138. checkedUserInfoList: JSON.stringify(this.choosedUserInfoList),
  139. checkedGroupInfoList: JSON.stringify(this.choosedGroupInfoList),
  140. });
  141. },
  142. getCheckedUsers(dataArray) {
  143. this.choosedUserInfoList = [...dataArray[0]];
  144. this.choosedGroupInfoList = [...dataArray[1]];
  145. },
  146. tryNavBack() {
  147. uni.showModal({
  148. title: "提示",
  149. content: "要保存设置吗?",
  150. showCancel: true,
  151. confirmText: "确认",
  152. cancelText: "取消",
  153. success: (res) => {
  154. this.transferData(res.cancel);
  155. },
  156. });
  157. },
  158. transferData(isCancel = false) {
  159. let pages = getCurrentPages();
  160. let prevPage = pages[pages.length - 2];
  161. prevPage.$vm.getWhoCanSee(
  162. isCancel
  163. ? this.originData
  164. : {
  165. choosedUserInfoList: this.choosedUserInfoList,
  166. choosedGroupInfoList: this.choosedGroupInfoList,
  167. permission: this.permission,
  168. choosedNameStr: this.choosedNameStr,
  169. },
  170. );
  171. uni.navigateBack({
  172. delta: 1,
  173. });
  174. },
  175. leftClick() {
  176. if (this.updateFlag) {
  177. this.tryNavBack();
  178. } else {
  179. this.transferData();
  180. }
  181. },
  182. },
  183. onBackPress(options) {
  184. console.log("onBackPress");
  185. if (options.from === "navigateBack") return false;
  186. if (this.updateFlag) {
  187. this.tryNavBack();
  188. } else {
  189. this.transferData(true);
  190. }
  191. return true;
  192. },
  193. };
  194. </script>
  195. <style lang="scss" scoped>
  196. .page_container {
  197. background-color: #f8f8f8;
  198. .nav_right_action {
  199. margin-right: 44rpx;
  200. .u-button--mini {
  201. height: 52rpx;
  202. }
  203. }
  204. .settings_wrap {
  205. margin-top: 24rpx;
  206. .setting_item {
  207. }
  208. .left_icon {
  209. width: 24px;
  210. height: 24px;
  211. margin-right: 24rpx;
  212. margin-top: 24rpx;
  213. image {
  214. width: 100%;
  215. height: 100%;
  216. }
  217. }
  218. .left_desc {
  219. font-size: 24rpx;
  220. color: #999;
  221. margin-top: 12rpx;
  222. view:last-child {
  223. color: #0089ff;
  224. margin-top: 12rpx;
  225. }
  226. }
  227. }
  228. }
  229. </style>