setting.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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. 'path': '/pages/my/adolescent',
  78. 'icon': '../../static/me/wd_icon_qingshaonianmoshi.png',
  79. 'propup': ''
  80. }
  81. ],
  82. moreSettings: [{
  83. 'name': '通知设置',
  84. 'desc': '',
  85. 'path': '/pages/my/pushSet',
  86. 'icon': '../../static/me/wd_icon_tonzhishezhi.png',
  87. 'propup': ''
  88. },
  89. {
  90. 'name': '服务条款',
  91. 'desc': '',
  92. 'path': '/pages/AboutUs/xieyi',
  93. 'icon': '../../static/me/wd_icon_fuwutiaokuan.png',
  94. 'propup': ''
  95. },
  96. {
  97. 'name': '接收内容推荐',
  98. 'switch': 1,
  99. 'desc': '',
  100. 'path': '',
  101. 'icon': '../../static/me/wd_icon_jieshouneirongtuijian.png',
  102. 'propup': ''
  103. },
  104. {
  105. 'name': '联系客服',
  106. 'desc': '',
  107. 'path': 'kefu',
  108. 'icon': '../../static/me/wd_icon_lianxikefu.png',
  109. 'propup': 'customPopup'
  110. }
  111. ],
  112. isContentRecommendation: true,
  113. }
  114. },
  115. onLoad() {
  116. this.getAppVersion()
  117. },
  118. onShow() {
  119. this.loadData();
  120. //
  121. var isContentRecommendation = getStorage('isContentRecommendation')
  122. if (isContentRecommendation != undefined) {
  123. this.isContentRecommendation = isContentRecommendation == 'false' ? false : true
  124. } else {
  125. setStorage('isContentRecommendation', true)
  126. }
  127. },
  128. methods: {
  129. openCustomPopup() {
  130. this.$refs.customerServicePopup.$refs.customPopup.open()
  131. },
  132. getAppVersion() {
  133. uni.getSystemInfo({
  134. success: (info) => {
  135. // app系统环境
  136. let appPlatform = info.platform;
  137. console.log("appPlatform", info)
  138. // #ifdef H5
  139. this.version = 'V' + info.appVersion;
  140. // #endif
  141. // #ifdef APP-PLUS
  142. plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
  143. this.version = 'V' + wgtinfo.version;
  144. });
  145. // #endif
  146. }
  147. });
  148. },
  149. switch1Change(e) {
  150. console.log(e.detail.value, 55555555555);
  151. setStorage('isContentRecommendation', e.detail.value)
  152. },
  153. onBack() { },
  154. chkSel() {
  155. if (this.sel == 1) {
  156. this.sel = 0;
  157. } else {
  158. this.sel = 1;
  159. }
  160. },
  161. goPage(page) {
  162. if (page == 'delete') {
  163. this.DelMem();
  164. } else if (page == 'yszc') {
  165. // #ifdef APP-PLUS
  166. plus.runtime.openURL('https://e.zhichao.art/web/yszc.php') // plus.runtime.openWeb(href);
  167. // #endif
  168. // #ifdef H5
  169. window.open('https://e.zhichao.art/web/yszc.php')
  170. // #endif
  171. } else if (page == 'kefu') {
  172. // let that = this;
  173. // // #ifdef APP-PLUS
  174. // plus.share.getServices(res => {
  175. // const wechat = res.find(i => i.id === 'weixin')
  176. // if (wechat) {
  177. // wechat.openCustomerServiceChat({
  178. // corpid: 'wwbc06aa8311b6ac08',
  179. // // url: 'https://work.weixin.qq.com/kfid/kfc4b0bcb4038d00a50'
  180. // url: that.myinfo.wxkf
  181. // }, src => {
  182. // console.log("success:")
  183. // }, err => {
  184. // console.log("error:")
  185. // })
  186. // } else {
  187. // uni.showToast({
  188. // title: '没有检测到微信,请先安装',
  189. // icon: "error"
  190. // });
  191. // }
  192. // });
  193. // // #endif
  194. this.openCustomPopup()
  195. } else if (page != '') {
  196. uni.navigateTo({
  197. url: page,
  198. })
  199. }
  200. },
  201. DelMem() {
  202. var that = this;
  203. this.$refs['DialogBox'].confirm({
  204. title: '警告',
  205. content: '1、注销账号是不可逆操作,该账号下所有一切资料一旦注销无法恢复;\n2、注销后,你账号下所有权益将被清除。',
  206. DialogType: 'inquiry',
  207. btn1: '否',
  208. btn2: '是',
  209. animation: 0
  210. }).then(() => {
  211. uni.request({
  212. url: that.$apiHost + '/My/delete', //检测是否已绑定
  213. data: {
  214. uuid: getApp().globalData.uuid
  215. },
  216. header: {
  217. 'content-type': 'application/json' //自定义请求头信息
  218. },
  219. success: (res) => {
  220. uni.removeStorageSync("wapptoken");
  221. uni.redirectTo({
  222. url: '/pages/login/login',
  223. })
  224. }
  225. });
  226. })
  227. },
  228. loadData() {
  229. console.log({
  230. uuid: getApp().globalData.uuid,
  231. skey: getApp().globalData.skey
  232. });
  233. uni.request({
  234. url: this.$apiHost + '/Web/getinfo',
  235. data: {
  236. uuid: getApp().globalData.uuid
  237. },
  238. header: {
  239. "content-type": "application/json",
  240. 'sign': getApp().globalData.headerSign
  241. },
  242. success: (res) => {
  243. console.log("----:", res.data);
  244. this.myinfo = res.data;
  245. },
  246. complete: (com) => {
  247. // uni.hideLoading();
  248. },
  249. fail: (e) => {
  250. console.log("----e:", e);
  251. }
  252. });
  253. },
  254. EditNickname() {
  255. let that = this;
  256. this.$refs['DialogBox'].confirm({
  257. title: '更改昵称',
  258. placeholder: '请输入修改的昵称',
  259. value: that.myinfo.nickname,
  260. DialogType: 'input',
  261. animation: 0
  262. }).then((res) => {
  263. if (res.value.length < 1) {
  264. uni.showToast({
  265. title: "请输入有效的昵称",
  266. icon: 'none'
  267. });
  268. return;
  269. }
  270. that.myinfo.nickname = res.value;
  271. let obj2 = {
  272. nickname: res.value
  273. }
  274. const postData = Object.assign({}, getApp().globalData.postHeader, obj2);
  275. uni.request({
  276. url: that.$apiHost + '/Gushi/editinfo', //检测是否已绑定
  277. data: postData,
  278. method: 'POST',
  279. header: {
  280. 'content-type': 'application/json', //自定义请求头信息
  281. 'Access-Control-Allow-Origin': '*'
  282. },
  283. success: (res) => {
  284. uni.showToast({
  285. title: res.data.str,
  286. icon: 'none'
  287. });
  288. }
  289. });
  290. })
  291. },
  292. logout() {
  293. this.$refs['DialogBox'].confirm({
  294. title: '提示',
  295. content: '确定要退出登录吗?',
  296. DialogType: 'inquiry',
  297. btn1: '取消',
  298. btn2: '确定',
  299. animation: 0
  300. }).then(() => {
  301. uni.removeStorageSync("wapptoken");
  302. uni.removeStorageSync("nickname");
  303. uni.removeStorageSync("avator");
  304. uni.removeStorageSync("mobile");
  305. uni.removeStorageSync("user_id");
  306. uni.redirectTo({
  307. url: '/pages/login/login',
  308. })
  309. })
  310. }
  311. }
  312. }
  313. </script>
  314. <style scoped lang="scss">
  315. @import 'setting.scss';
  316. </style>