setting.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  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" :checked="isContentRecommendations"
  31. 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></br>
  40. <text>杭州智潮创意科技有限公司</text>
  41. </view>
  42. <!-- 退出登录按钮 -->
  43. <view class="btn_submit" @click="logout">退出登录</view>
  44. <DialogBox ref="DialogBox"></DialogBox>
  45. <CustomerServicePopup ref="customerServicePopup"></CustomerServicePopup>
  46. </view>
  47. </template>
  48. <script>
  49. import CustomerServicePopup from "@/components/CustomerServicePopup/CustomerServicePopup.vue";
  50. import { getStorage, setStorage, removeStorage } from "@/common/util.js";
  51. import { mapState, mapMutations ,mapGetters} from 'vuex';
  52. export default {
  53. components: { CustomerServicePopup },
  54. computed: {
  55. ...mapState('rightsManagement',['isContentRecommendation']),
  56. ...mapGetters('rightsManagement',['isContent'])
  57. },
  58. data() {
  59. return {
  60. title: "",
  61. sel: 1,
  62. myinfo: {},
  63. version: "",
  64. basicSettings: [
  65. {
  66. name: "账户与安全",
  67. desc: "",
  68. path: "/pages/my/security",
  69. icon: "../../static/me/wd_icon_zhanghuyuanquan.png",
  70. propup: "",
  71. },
  72. {
  73. name: "基本资料",
  74. desc: "",
  75. path: "/pages/my/editInfo",
  76. icon: "../../static/me/wd_icon_jibenziliao.png",
  77. propup: "",
  78. },
  79. {
  80. name: "青少年模式",
  81. switch: 0,
  82. desc: "",
  83. // 'path': '/pages/my/idcheck',实名认证
  84. path: "/pages/my/adolescent",
  85. icon: "../../static/me/wd_icon_qingshaonianmoshi.png",
  86. propup: "",
  87. },
  88. {
  89. name: "收货地址",
  90. switch: 0,
  91. desc: "",
  92. // 'path': '/pages/my/idcheck',实名认证
  93. path: "/pages/crowdFunding/receivingAddress",
  94. icon: "../../static/me/wd_icon_shouhuodizhi.png",
  95. propup: "",
  96. },
  97. ],
  98. moreSettings: [
  99. {
  100. name: "发起众筹",
  101. desc: "",
  102. path: "InitiateCrowdfunding",
  103. icon: "../../static/me/InitiateCrowdfunding.png",
  104. propup: "",
  105. },
  106. {
  107. name: "通知设置",
  108. desc: "",
  109. path: "pushSet",
  110. icon: "../../static/me/wd_icon_tonzhishezhi.png",
  111. propup: "",
  112. },
  113. {
  114. name: "服务条款",
  115. desc: "",
  116. path: "/pages/AboutUs/xieyi",
  117. icon: "../../static/me/wd_icon_fuwutiaokuan.png",
  118. propup: "",
  119. },
  120. {
  121. name: "接收内容推荐",
  122. switch: 1,
  123. desc: "",
  124. path: "",
  125. icon: "../../static/me/wd_icon_jieshouneirongtuijian.png",
  126. propup: "",
  127. },
  128. {
  129. name: "联系客服",
  130. desc: "",
  131. path: "kefu",
  132. icon: "../../static/me/wd_icon_lianxikefu.png",
  133. propup: "customPopup",
  134. },
  135. ],
  136. isContentRecommendations: true,
  137. };
  138. },
  139. onLoad() {
  140. this.getAppVersion();
  141. },
  142. onShow() {
  143. this.loadData();
  144. if (this.isContent) {
  145. this.isContentRecommendations = true
  146. } else {
  147. this.isContentRecommendations = false
  148. }
  149. },
  150. methods: {
  151. ...mapMutations('rightsManagement',[ 'setIsContentRecommendation']),
  152. ...mapMutations('switchingModule', ['deleteInformation']),
  153. openCustomPopup() {
  154. this.$refs.customerServicePopup.open();
  155. },
  156. getAppVersion() {
  157. uni.getSystemInfo({
  158. success: (info) => {
  159. // app系统环境
  160. let appPlatform = info.platform;
  161. console.log("appPlatform", info);
  162. // #ifdef H5
  163. this.version = "V" + info.appVersion;
  164. // #endif
  165. // #ifdef APP-PLUS
  166. plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
  167. this.version = "V" + wgtinfo.version;
  168. });
  169. // #endif
  170. },
  171. });
  172. },
  173. switch1Change(e) {
  174. this.setIsContentRecommendation(e.detail.value);
  175. },
  176. onBack() { },
  177. chkSel() {
  178. if (this.sel == 1) {
  179. this.sel = 0;
  180. } else {
  181. this.sel = 1;
  182. }
  183. },
  184. goPage(page) {
  185. if (page == "delete") {
  186. this.DelMem();
  187. } else if (page == "yszc") {
  188. // #ifdef APP-PLUS
  189. plus.runtime.openURL("https://e.zhichao.art/web/yszc.php"); // plus.runtime.openWeb(href);
  190. // #endif
  191. // #ifdef H5
  192. window.open("https://e.zhichao.art/web/yszc.php");
  193. // #endif
  194. } else if (page == "kefu") {
  195. // let that = this;
  196. // // #ifdef APP-PLUS
  197. // plus.share.getServices(res => {
  198. // const wechat = res.find(i => i.id === 'weixin')
  199. // if (wechat) {
  200. // wechat.openCustomerServiceChat({
  201. // corpid: 'wwbc06aa8311b6ac08',
  202. // // url: 'https://work.weixin.qq.com/kfid/kfc4b0bcb4038d00a50'
  203. // url: that.myinfo.wxkf
  204. // }, src => {
  205. // console.log("success:")
  206. // }, err => {
  207. // console.log("error:")
  208. // })
  209. // } else {
  210. // uni.showToast({
  211. // title: '没有检测到微信,请先安装',
  212. // icon: "error"
  213. // });
  214. // }
  215. // });
  216. // // #endif
  217. this.openCustomPopup();
  218. }else if (page == "InitiateCrowdfunding") {
  219. uni.showModal({
  220. title: "温馨提示",
  221. content: "请使用电脑端登录,认证后发起众筹",
  222. paratext: "(复制下方链接,电脑登录)",
  223. cancelText: "取消",
  224. confirmText: "复制链接",
  225. success: (res) => {
  226. if (res.confirm) {
  227. uni.setClipboardData({
  228. data: 'https://zhichao.art/zc/',
  229. success: () => {
  230. uni.showToast({
  231. title: '链接已复制',
  232. icon: 'success'
  233. })
  234. },
  235. fail: () => {
  236. uni.showToast({
  237. title: '复制失败',
  238. icon: 'none'
  239. })
  240. }
  241. })
  242. }
  243. }
  244. });
  245. } else if (page == "pushSet") {
  246. // #ifdef APP-PLUS
  247. if (uni.getSystemInfoSync().platform === 'android') {
  248. const main = plus.android.runtimeMainActivity();
  249. const NotificationManagerCompat = plus.android.importClass('androidx.core.app.NotificationManagerCompat');
  250. const Context = plus.android.importClass('android.content.Context');
  251. // 获取NotificationManagerCompat实例
  252. const notificationManager = NotificationManagerCompat.from(main);
  253. // 检查通知权限
  254. const areNotificationsEnabled = notificationManager.areNotificationsEnabled();
  255. uni.showModal({
  256. title: "通知设置",
  257. content: "可进行消息通知管理",
  258. paratext: "通知可能包括:悬浮消息通知、锁屏通知、桌面角标提醒通知",
  259. cancelText: "取消",
  260. confirmText: "确定",
  261. success: (res) => {
  262. if (res.confirm) {
  263. const Intent = plus.android.importClass('android.content.Intent');
  264. const Settings = plus.android.importClass('android.provider.Settings');
  265. const Uri = plus.android.importClass('android.net.Uri');
  266. const intent = new Intent();
  267. intent.setAction(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
  268. intent.putExtra(Settings.EXTRA_APP_PACKAGE, main.getPackageName());
  269. main.startActivity(intent);
  270. }
  271. },
  272. });
  273. } else {
  274. // iOS
  275. const UIApplication = plus.ios.import("UIApplication");
  276. const NSURL = plus.ios.import("NSURL");
  277. const setting = NSURL.URLWithString("app-settings:");
  278. const application = UIApplication.sharedApplication();
  279. application.openURL(setting);
  280. }
  281. // #endif
  282. // #ifdef H5
  283. uni.showToast({
  284. title: 'H5环境不支持此功能',
  285. icon: 'none'
  286. });
  287. // #endif
  288. } else if (page != "") {
  289. uni.navigateTo({
  290. url: page,
  291. });
  292. }
  293. },
  294. DelMem() {
  295. var that = this;
  296. this.$refs["DialogBox"]
  297. .confirm({
  298. title: "警告",
  299. content:
  300. "1、注销账号是不可逆操作,该账号下所有一切资料一旦注销无法恢复;\n2、注销后,你账号下所有权益将被清除。",
  301. DialogType: "inquiry",
  302. btn1: "否",
  303. btn2: "是",
  304. animation: 0,
  305. })
  306. .then(() => {
  307. uni.request({
  308. url: that.$apiHost + "/My/delete", //检测是否已绑定
  309. data: {
  310. uuid: getApp().globalData.uuid,
  311. },
  312. header: {
  313. "content-type": "application/json", //自定义请求头信息
  314. },
  315. success: (res) => {
  316. uni.removeStorageSync("wapptoken");
  317. uni.redirectTo({
  318. url: "/pages/login/login",
  319. });
  320. },
  321. });
  322. });
  323. },
  324. loadData() {
  325. console.log({
  326. uuid: getApp().globalData.uuid,
  327. skey: getApp().globalData.skey,
  328. });
  329. uni.request({
  330. url: this.$apiHost + "/Web/getinfo",
  331. data: {
  332. uuid: getApp().globalData.uuid,
  333. },
  334. header: {
  335. "content-type": "application/json",
  336. sign: getApp().globalData.headerSign,
  337. },
  338. success: (res) => {
  339. console.log("----:", res.data);
  340. this.myinfo = res.data;
  341. },
  342. complete: (com) => {
  343. // uni.hideLoading();
  344. },
  345. fail: (e) => {
  346. console.log("----e:", e);
  347. },
  348. });
  349. },
  350. EditNickname() {
  351. let that = this;
  352. this.$refs["DialogBox"]
  353. .confirm({
  354. title: "更改昵称",
  355. placeholder: "请输入修改的昵称",
  356. value: that.myinfo.nickname,
  357. DialogType: "input",
  358. animation: 0,
  359. })
  360. .then((res) => {
  361. if (res.value.length < 1) {
  362. uni.showToast({
  363. title: "请输入有效的昵称",
  364. icon: "none",
  365. });
  366. return;
  367. }
  368. that.myinfo.nickname = res.value;
  369. let obj2 = {
  370. nickname: res.value,
  371. };
  372. const postData = Object.assign(
  373. {},
  374. getApp().globalData.postHeader,
  375. obj2
  376. );
  377. uni.request({
  378. url: that.$apiHost + "/Gushi/editinfo", //检测是否已绑定
  379. data: postData,
  380. method: "POST",
  381. header: {
  382. "content-type": "application/json", //自定义请求头信息
  383. "Access-Control-Allow-Origin": "*",
  384. },
  385. success: (res) => {
  386. uni.showToast({
  387. title: res.data.str,
  388. icon: "none",
  389. });
  390. },
  391. });
  392. });
  393. },
  394. logout() {
  395. this.$refs["DialogBox"]
  396. .confirm({
  397. title: "提示",
  398. content: "确定要退出登录吗?",
  399. DialogType: "inquiry",
  400. btn1: "取消",
  401. btn2: "确定",
  402. animation: 0,
  403. })
  404. .then(() => {
  405. uni.removeStorageSync("wapptoken");
  406. uni.removeStorageSync("nickname");
  407. uni.removeStorageSync("avator");
  408. uni.removeStorageSync("mobile");
  409. uni.removeStorageSync("uuid");
  410. uni.removeStorageSync("user_id");
  411. uni.removeStorageSync("is_login");
  412. removeStorage("isContentRecommendation");
  413. this.deleteInformation();
  414. uni.redirectTo({
  415. url: "/pages/login/login",
  416. });
  417. });
  418. },
  419. copyText(text) {
  420. uni.setClipboardData({
  421. data: text,
  422. success: () => {
  423. uni.showToast({
  424. title: '复制成功',
  425. icon: 'success'
  426. })
  427. },
  428. fail: () => {
  429. uni.showToast({
  430. title: '复制失败',
  431. icon: 'none'
  432. })
  433. }
  434. })
  435. },
  436. },
  437. };
  438. </script>
  439. <style scoped lang="scss">
  440. @import "setting.scss";
  441. </style>