index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <template>
  2. <view>
  3. <!-- <view class="list_box" @click="bindTo('/my/setting/mimi')">
  4. <view class="box_left">隐私政策</view>
  5. <u-icon name="arrow-right"></u-icon>
  6. </view>
  7. <view class="list_box" @click="bindTo('/my/setting/xieyi')">
  8. <view class="box_left">用户协议</view>
  9. <u-icon name="arrow-right"></u-icon>
  10. </view>
  11. <view class="list_box" @click="bindTo('/my/setting/logOff')">
  12. <view class="box_left">用户注销</view>
  13. <u-icon name="arrow-right"></u-icon>
  14. </view>
  15. <view class="login_btn" @click="bindOut()">退出登录</view> -->
  16. <view class="titls2 " style="margin-top: 25rpx;">
  17. 隐私管理
  18. </view>
  19. <view class="boxs">
  20. <view class="flex align-center justify-between padding-lr">
  21. <view style="line-height: 40rpx;">
  22. <view>位置信息共享</view>
  23. <view style="color: #999;font-size: 24rpx;">控制是否向平台共享实时位置</view>
  24. </view>
  25. <view class="order_money">
  26. <switch color="#fe6b01!important" checked @change="switch1Change" />
  27. </view>
  28. </view>
  29. <!-- <view class="flex align-center justify-between padding-lr">
  30. <view style="line-height: 40rpx;">
  31. <view>个人信息可见范围</view>
  32. <view style="color: #999;font-size: 24rpx;">设置其他用户可见的信息</view>
  33. </view>
  34. <view class="order_money">
  35. <u-icon name="arrow-right"></u-icon>
  36. </view>
  37. </view> -->
  38. <view class="flex align-center justify-between padding-lr" style="margin-top: 30rpx;">
  39. <view style="line-height: 40rpx;">
  40. <view>消息推送权限</view>
  41. <view style="color: #999;font-size: 24rpx;">管理通知和消息接收</view>
  42. </view>
  43. <view class="order_money">
  44. <switch color="#fe6b01!important" checked @change="switch1Change" />
  45. </view>
  46. </view>
  47. </view>
  48. <view class="titls2 " style="margin-top: 30rpx;">
  49. 紧急联系人
  50. </view>
  51. <view class="boxs">
  52. <!-- 外层容器 -->
  53. <view class="flex align-center padding-tb-sm" v-for="(item, index) in personList" :key="index">
  54. <!-- 显示头像 -->
  55. <view>
  56. <image v-if="globalImages" :src="globalImages + 'images/order/chengcheren.png'" style="width: 80rpx;height: 80rpx;" mode=""></image>
  57. </view>
  58. <!-- 显示姓名和关系、电话 -->
  59. <view style="margin-left: 30rpx; line-height: 40rpx;">
  60. <view>{{ item.name }}</view>
  61. <view style="color: #999;">{{ item.relationship }} · {{ item.phone }}</view>
  62. </view>
  63. <!-- 编辑图标 -->
  64. <view style="position: absolute; right: 130rpx;" @tap="handleEdit(item)">
  65. <image v-if="globalImages" :src="globalImages + 'images/order/xiugai.png'" style="width: 36rpx;height: 36rpx;" mode="">
  66. </image>
  67. </view>
  68. <!-- 删除图标 -->
  69. <view style="position: absolute; right: 60rpx;" @tap="handleDelete(item.id, index)">
  70. <image v-if="globalImages" :src="globalImages + 'images/order/shanchu.png'" style="width: 36rpx;height: 36rpx;" mode="">
  71. </image>
  72. </view>
  73. </view>
  74. </view>
  75. <view class="login_btn" v-if="personList.length < 3" @tap="handleAddContact">添加紧急联系人</view>
  76. <view style="color: #999; font-size: 22rpx; text-align: center;line-height: 80rpx;">
  77. 最多可添加三位紧急联系人
  78. </view>
  79. </view>
  80. </template>
  81. <script>
  82. import { waitForGlobalImages } from '@/utils/globalImageLoader'
  83. export default {
  84. data() {
  85. return {
  86. // 定义人员列表数据
  87. personList: [],
  88. maxContact: 3, // 最大联系人数量
  89. // 添加/编辑时的临时数据
  90. tempContact: {
  91. name: '',
  92. relationship: '',
  93. phone: '',
  94. remark: '',
  95. // userId: null,
  96. },
  97. globalImages: ''
  98. }
  99. },
  100. onShow() {
  101. uni.$on('updateContact', (contact) => {
  102. this.receiveContact(contact); // 调用之前定义的接收方法
  103. });
  104. },
  105. onLoad() {
  106. this.parson()
  107. waitForGlobalImages().then((path) => {
  108. console.log('✅ 全局图片路径:', path)
  109. this.globalImages = path
  110. })
  111. },
  112. onUnload() {
  113. uni.$off('updateContact'); // 移除监听避免内存泄漏
  114. },
  115. methods: {
  116. parson () {
  117. this.$Request.getT('/app/emergency/selectDriverList').then(res => {
  118. if (res.code === 0) {
  119. this.personList = res.data;
  120. }
  121. });
  122. },
  123. switch1Change: function(e) {
  124. console.log('switch1 发生 change 事件,携带值为', e.detail.value)
  125. },
  126. bindTo(name) {
  127. let token = this.$queue.getData("token");
  128. if (token) {
  129. uni.navigateTo({
  130. url: name
  131. })
  132. }
  133. },
  134. // 跳转添加页面
  135. handleAddContact() {
  136. if (this.personList.length >= this.maxContact) {
  137. uni.showToast({
  138. title: '最多添加3位联系人',
  139. icon: 'none'
  140. });
  141. return;
  142. }
  143. // 重置临时数据(避免编辑后残留)
  144. this.tempContact = {
  145. name: '',
  146. relationship: '',
  147. phone: '',
  148. avatarImg: ''
  149. };
  150. // 跳转添加页面(携带type=add标识)
  151. let token = this.$queue.getData("token");
  152. if (token) {
  153. uni.navigateTo({
  154. url: '/my/setting/addemergencycontact?type=add'
  155. });
  156. }
  157. },
  158. // 接收添加/编辑后的回调数据(假设通过全局事件或页面传参)
  159. receiveContact(contact) {
  160. console.log(contact, 'contactcontact');
  161. const index = this.personList.findIndex(item => item.id === contact.id);
  162. this.parson()
  163. },
  164. handleEdit(contact) {
  165. // 填充临时数据(用于编辑页面回显)
  166. this.tempContact = { ...contact };
  167. // 跳转编辑页面(携带type=edit和id)
  168. let token = this.$queue.getData("token");
  169. if (token) {
  170. uni.navigateTo({ url: `/my/setting/addemergencycontact?type=edit&id=${contact.id}` });
  171. }
  172. },
  173. handleDelete(ids, index) {
  174. uni.showModal({
  175. title: '确认删除',
  176. content: '是否删除该紧急联系人?',
  177. success: (res) => {
  178. if (res.confirm) {
  179. let data = {
  180. id: ids
  181. }
  182. this.$Request.postT('/app/emergency/deleteEmergency', data)
  183. .then(res => {
  184. if (res.code === 0) {
  185. uni.showToast({ title: '删除成功', icon: 'success' });
  186. this.parson()
  187. } else {
  188. uni.showToast({ title: res.msg || '删除失败', icon: 'none' });
  189. }
  190. })
  191. .catch(err => {
  192. console.error('删除失败:', err);
  193. uni.showToast({ title: '网络错误', icon: 'none' });
  194. });
  195. }
  196. }
  197. });
  198. },
  199. bindOut() {
  200. uni.showModal({
  201. title: '退出登录',
  202. content: '是否退出登录',
  203. success: function(res) {
  204. if (res.confirm) {
  205. uni.setStorageSync('weixinPhone', false)
  206. uni.removeStorageSync('sendDataList')
  207. uni.removeStorageSync('sessionkey')
  208. uni.removeStorageSync("image_url")
  209. uni.removeStorageSync("userId")
  210. uni.removeStorageSync("status")
  211. uni.removeStorageSync("nickName")
  212. uni.removeStorageSync("token")
  213. uni.removeStorageSync("mobile")
  214. // uni.showModal({
  215. // showCancel: false,
  216. // title: '退出登录',
  217. // content: res.msg,
  218. // });
  219. uni.navigateBack()
  220. // uni.navigateBack({
  221. // success: () => {
  222. // let page = getCurrentPages().pop(); //跳转页面成功之后
  223. // if (page) {
  224. // let e = {};
  225. // page.onShow(); //执行上个页面的方法
  226. // };
  227. // }
  228. // })
  229. // console.log('用户点击确定');
  230. } else if (res.cancel) {
  231. console.log('用户点击取消');
  232. }
  233. }
  234. });
  235. }
  236. }
  237. }
  238. </script>
  239. <style>
  240. page {
  241. background: #f0f0f0;
  242. }
  243. .list_box {
  244. display: flex;
  245. height: 110rpx;
  246. margin: 0 30rpx;
  247. }
  248. .box_left {
  249. flex: 1;
  250. display: flex;
  251. justify-content: left;
  252. align-items: center;
  253. }
  254. .use_image image {
  255. width: 60rpx;
  256. height: 60rpx;
  257. }
  258. .login_btn {
  259. width: 90%;
  260. margin: 0 auto;
  261. text-align: center;
  262. background: #fe6b01;
  263. height: 80rpx;
  264. border-radius: 16rpx;
  265. color: #ffffff;
  266. line-height: 80rpx;
  267. margin-top: 60rpx;
  268. }
  269. .titls2 {
  270. font-size: 32rpx;
  271. font-family: PingFang SC;
  272. color: #333333;
  273. padding: 0 30rpx;
  274. }
  275. .sj_name {
  276. font-family: PingFang SC;
  277. font-weight: 500;
  278. font-size: 24rpx;
  279. color: #999999;
  280. }
  281. .boxs {
  282. background: #FFFFFF;
  283. border-radius: 24rpx;
  284. margin: 30rpx;
  285. padding: 30rpx;
  286. }
  287. </style>