setting.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <template>
  2. <view class="page">
  3. <view class="list_info">
  4. <view class="">
  5. <!-- 基础设置组 -->
  6. <view class="group-header">基础设置</view>
  7. <view class="item basic" v-for="(item, index) in basicSettings" :key="item.name + index"
  8. @click="goPage(item.path)">
  9. <view class="item-left">
  10. <image class="icon" :src="item.icon" mode="widthFix"></image>
  11. <text>{{ item.name }}</text>
  12. </view>
  13. <view class="item-right">
  14. <switch v-if="item.switch == 1" checked class="custom-switch" color="#acf934"
  15. style="transform:scale(0.7)" />
  16. <image v-else class="arrow" src="../../static/me/arrow_right_gray.png" mode="widthFix"></image>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="">
  21. <!-- 更多设置组 -->
  22. <view class="group-header" style="margin-top: 20rpx;">更多</view>
  23. <view class="item more" v-for="(item, index) in moreSettings" :key="index + item.name"
  24. @click=" goPage(item.path, item)">
  25. <view class="item-left">
  26. <image class="icon" :src="item.icon" mode="widthFix"></image>
  27. <text>{{ item.name }}</text>
  28. </view>
  29. <view class="item-right">
  30. <switch v-if="item.switch == 1" color="#acf934" @change="switch1Change"
  31. :checked="isContentRecommendation" class="custom-switch" style="transform:scale(0.7)" />
  32. <image v-else class="arrow" src="../../static/me/arrow_right_gray.png" mode="widthFix"></image>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <!-- 版本信息 -->
  38. <view class="version-info">
  39. <text>版本号 {{ version }}</text>
  40. </view>
  41. <!-- 退出登录按钮 -->
  42. <view class="btn_submit" @click="logout">退出登录</view>
  43. <DialogBox ref="DialogBox"></DialogBox>
  44. <CustomerServicePopup ref="customerServicePopup"></CustomerServicePopup>
  45. </view>
  46. </template>
  47. <script>
  48. import CustomerServicePopup from '@/components/CustomerServicePopup/CustomerServicePopup.vue'
  49. import { getStorage, setStorage, removeStorage } from '@/common/util.js'
  50. export default {
  51. components: { CustomerServicePopup },
  52. data() {
  53. return {
  54. title: '',
  55. sel: 1,
  56. myinfo: {},
  57. version: '',
  58. basicSettings: [{
  59. 'name': '账户与安全',
  60. 'desc': '',
  61. 'path': '/pages/my/security',
  62. 'icon': '../../static/me/wd_icon_zhanghuyuanquan.png',
  63. 'propup': ''
  64. },
  65. {
  66. 'name': '基本资料',
  67. 'desc': '',
  68. 'path': '/pages/my/editInfo',
  69. 'icon': '../../static/me/wd_icon_jibenziliao.png',
  70. 'propup': ''
  71. },
  72. {
  73. 'name': '青少年模式',
  74. 'switch': 0,
  75. 'desc': '',
  76. 'path': '/pages/my/idcheck',
  77. 'icon': '../../static/me/wd_icon_qingshaonianmoshi.png',
  78. 'propup': ''
  79. }
  80. ],
  81. moreSettings: [{
  82. 'name': '通知设置',
  83. 'desc': '',
  84. 'path': '/pages/my/pushSet',
  85. 'icon': '../../static/me/wd_icon_tonzhishezhi.png',
  86. 'propup': ''
  87. },
  88. {
  89. 'name': '服务条款',
  90. 'desc': '',
  91. 'path': '/pages/AboutUs/xieyi',
  92. 'icon': '../../static/me/wd_icon_fuwutiaokuan.png',
  93. 'propup': ''
  94. },
  95. {
  96. 'name': '接收内容推荐',
  97. 'switch': 1,
  98. 'desc': '',
  99. 'path': '',
  100. 'icon': '../../static/me/wd_icon_jieshouneirongtuijian.png',
  101. 'propup': ''
  102. },
  103. {
  104. 'name': '联系客服',
  105. 'desc': '',
  106. 'path': 'kefu',
  107. 'icon': '../../static/me/wd_icon_lianxikefu.png',
  108. 'propup': 'customPopup'
  109. }
  110. ],
  111. isContentRecommendation: true,
  112. }
  113. },
  114. onLoad() {
  115. this.getAppVersion()
  116. },
  117. onShow() {
  118. this.loadData();
  119. //
  120. var isContentRecommendation = getStorage('isContentRecommendation')
  121. if (isContentRecommendation != undefined) {
  122. this.isContentRecommendation = isContentRecommendation == 'false' ? false : true
  123. } else {
  124. setStorage('isContentRecommendation', true)
  125. }
  126. },
  127. methods: {
  128. openCustomPopup() {
  129. this.$refs.customerServicePopup.$refs.customPopup.open()
  130. },
  131. getAppVersion() {
  132. uni.getSystemInfo({
  133. success: (info) => {
  134. // app系统环境
  135. let appPlatform = info.platform;
  136. console.log("appPlatform", info)
  137. // #ifdef H5
  138. this.version = 'V' + info.appVersion;
  139. // #endif
  140. // #ifdef APP-PLUS
  141. plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
  142. this.version = 'V' + wgtinfo.version;
  143. });
  144. // #endif
  145. }
  146. });
  147. },
  148. switch1Change(e) {
  149. console.log(e.detail.value, 55555555555);
  150. setStorage('isContentRecommendation', e.detail.value)
  151. },
  152. onBack() { },
  153. chkSel() {
  154. if (this.sel == 1) {
  155. this.sel = 0;
  156. } else {
  157. this.sel = 1;
  158. }
  159. },
  160. goPage(page) {
  161. if (page == 'delete') {
  162. this.DelMem();
  163. } else if (page == 'yszc') {
  164. // #ifdef APP-PLUS
  165. plus.runtime.openURL('https://e.zhichao.art/web/yszc.php') // plus.runtime.openWeb(href);
  166. // #endif
  167. // #ifdef H5
  168. window.open('https://e.zhichao.art/web/yszc.php')
  169. // #endif
  170. } else if (page == 'kefu') {
  171. // let that = this;
  172. // // #ifdef APP-PLUS
  173. // plus.share.getServices(res => {
  174. // const wechat = res.find(i => i.id === 'weixin')
  175. // if (wechat) {
  176. // wechat.openCustomerServiceChat({
  177. // corpid: 'wwbc06aa8311b6ac08',
  178. // // url: 'https://work.weixin.qq.com/kfid/kfc4b0bcb4038d00a50'
  179. // url: that.myinfo.wxkf
  180. // }, src => {
  181. // console.log("success:")
  182. // }, err => {
  183. // console.log("error:")
  184. // })
  185. // } else {
  186. // uni.showToast({
  187. // title: '没有检测到微信,请先安装',
  188. // icon: "error"
  189. // });
  190. // }
  191. // });
  192. // // #endif
  193. this.openCustomPopup()
  194. } else if (page != '') {
  195. uni.navigateTo({
  196. url: page,
  197. })
  198. }
  199. },
  200. DelMem() {
  201. var that = this;
  202. this.$refs['DialogBox'].confirm({
  203. title: '警告',
  204. content: '1、注销账号是不可逆操作,该账号下所有一切资料一旦注销无法恢复;\n2、注销后,你账号下所有权益将被清除。',
  205. DialogType: 'inquiry',
  206. btn1: '否',
  207. btn2: '是',
  208. animation: 0
  209. }).then(() => {
  210. uni.request({
  211. url: that.$apiHost + '/My/delete', //检测是否已绑定
  212. data: {
  213. uuid: getApp().globalData.uuid
  214. },
  215. header: {
  216. 'content-type': 'application/json' //自定义请求头信息
  217. },
  218. success: (res) => {
  219. uni.removeStorageSync("wapptoken");
  220. uni.redirectTo({
  221. url: '/pages/login/login',
  222. })
  223. }
  224. });
  225. })
  226. },
  227. loadData() {
  228. console.log({
  229. uuid: getApp().globalData.uuid,
  230. skey: getApp().globalData.skey
  231. });
  232. uni.request({
  233. url: this.$apiHost + '/Web/getinfo',
  234. data: {
  235. uuid: getApp().globalData.uuid
  236. },
  237. header: {
  238. "content-type": "application/json",
  239. 'sign': getApp().globalData.headerSign
  240. },
  241. success: (res) => {
  242. console.log("----:", res.data);
  243. this.myinfo = res.data;
  244. },
  245. complete: (com) => {
  246. // uni.hideLoading();
  247. },
  248. fail: (e) => {
  249. console.log("----e:", e);
  250. }
  251. });
  252. },
  253. EditNickname() {
  254. let that = this;
  255. this.$refs['DialogBox'].confirm({
  256. title: '更改昵称',
  257. placeholder: '请输入修改的昵称',
  258. value: that.myinfo.nickname,
  259. DialogType: 'input',
  260. animation: 0
  261. }).then((res) => {
  262. if (res.value.length < 1) {
  263. uni.showToast({
  264. title: "请输入有效的昵称",
  265. icon: 'none'
  266. });
  267. return;
  268. }
  269. that.myinfo.nickname = res.value;
  270. let obj2 = {
  271. nickname: res.value
  272. }
  273. const postData = Object.assign({}, getApp().globalData.postHeader, obj2);
  274. uni.request({
  275. url: that.$apiHost + '/Gushi/editinfo', //检测是否已绑定
  276. data: postData,
  277. method: 'POST',
  278. header: {
  279. 'content-type': 'application/json', //自定义请求头信息
  280. 'Access-Control-Allow-Origin': '*'
  281. },
  282. success: (res) => {
  283. uni.showToast({
  284. title: res.data.str,
  285. icon: 'none'
  286. });
  287. }
  288. });
  289. })
  290. },
  291. logout() {
  292. this.$refs['DialogBox'].confirm({
  293. title: '提示',
  294. content: '确定要退出登录吗?',
  295. DialogType: 'inquiry',
  296. btn1: '取消',
  297. btn2: '确定',
  298. animation: 0
  299. }).then(() => {
  300. uni.removeStorageSync("wapptoken");
  301. uni.removeStorageSync("nickname");
  302. uni.removeStorageSync("avator");
  303. uni.removeStorageSync("mobile");
  304. uni.removeStorageSync("user_id");
  305. uni.redirectTo({
  306. url: '/pages/login/login',
  307. })
  308. })
  309. }
  310. }
  311. }
  312. </script>
  313. <style scoped lang="scss">
  314. @import 'setting.scss';
  315. </style>