index.vue 10 KB

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