setting.vue 7.3 KB

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