index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <view>
  3. <view class="ceng" @click="exitPop()" v-if="showPrivacy"></view>
  4. <view class="pop-protocol" :style="'bottom:' + XyBottom">
  5. <view class="privacy-exit ddflex" @click="exitPop()">
  6. <image :src="picUrlss+'privacy_exit.png'"></image>退出应用
  7. </view>
  8. <!-- <image src="../../static/pages/images/close1.png" class="update-close1" @click="exit"></image> -->
  9. <view class="pop-tit">用户协议与隐私保护提醒</view>
  10. <view class="pop-con">
  11. <view>感谢使用「{{config.CONFIG_PROJECT_TITLE}}」。</view>
  12. 为保障您的个人信息安全,请在使用前仔细阅读<text @tap="handleOpenPrivacyContract">{{name}}</text><text
  13. @click="jump('/mine/page/page?title=用户协议&isXieyi=true')">《用户协议》</text>和<text
  14. @click="jump('/mine/page/page?title=隐私声明&isYinsi=true')">《隐私声明》</text>。如您同意请继续。
  15. </view>
  16. <view class="pop-btn">
  17. <!-- <view class="pop-no">退出应用</view> -->
  18. <button class="pop-agree" id="agree-btn" open-type="agreePrivacyAuthorization"
  19. @agreeprivacyauthorization="handleAgreePrivacyAuthorization"
  20. v-if="userInfo.mobile || (!userInfo.mobile && !isBindMobile)">已知晓,同意并继续</button>
  21. <button class="pop-agree" id="agree-btn" open-type="getPhoneNumber|agreePrivacyAuthorization"
  22. @getphonenumber="handleGetPhoneNumber" @agreeprivacyauthorization="handleAgreePrivacyAuthorization"
  23. v-else>已知晓,同意并继续</button>
  24. <!-- <view class="pop-agree" @click="agn()">同意并继续</view> -->
  25. </view>
  26. </view>
  27. <block v-if="showExit">
  28. <view class="ceng" style="z-index: 104;"></view>
  29. <view class="privacy-pop">
  30. <view class="privacy-con">
  31. 应国家相关法律要求,您在使用「{{config.CONFIG_PROJECT_TITLE}}」之前,必须阅读并同意<text
  32. @tap="handleOpenPrivacyContract">{{name}}</text>。给您带来不便,敬请谅解。
  33. </view>
  34. <view class="privacy-btn ddflex">
  35. <view class="privacy-jj" @click="exit()">关闭退出</view>
  36. <button class="privacy-agree" id="agree-btn" open-type="agreePrivacyAuthorization"
  37. @agreeprivacyauthorization="handleAgreePrivacyAuthorization"
  38. v-if="userInfo.mobile || (!userInfo.mobile && !isBindMobile)">继续使用</button>
  39. <button class="privacy-agree" id="agree-btn" open-type="getPhoneNumber|agreePrivacyAuthorization"
  40. @getphonenumber="handleGetPhoneNumber"
  41. @agreeprivacyauthorization="handleAgreePrivacyAuthorization" v-else>继续使用</button>
  42. </view>
  43. </view>
  44. </block>
  45. </view>
  46. </template>
  47. <script>
  48. const app = getApp();
  49. const req = require('../../utils/request.js');
  50. export default {
  51. data() {
  52. return {
  53. picUrlss: req.public.picUrls,
  54. config: '',
  55. name: '',
  56. showPrivacy: false,
  57. XyBottom: '-100%',
  58. userInfo: '',
  59. showExit: false
  60. };
  61. },
  62. props: {
  63. isUpdate: {
  64. type: Boolean,
  65. default: false
  66. },
  67. isBindMobile: {
  68. type: Boolean,
  69. default: true
  70. },
  71. isTimeout: {
  72. type: Boolean,
  73. default: true
  74. }
  75. },
  76. async mounted() {
  77. await this.init();
  78. },
  79. methods: {
  80. init() {
  81. if (req.getStorage('configRes')) this.config = JSON.parse(req.getStorage('configRes'));
  82. else this.getConfig();
  83. setTimeout(async res => {
  84. this.userInfo = await req.getStorage('userInfo');
  85. await this.getPrivacySet();
  86. }, this.isTimeout ? 2000 : 0)
  87. },
  88. getPrivacySet() {
  89. // #ifdef MP-WEIXIN
  90. return new Promise((resolve, reject) => {
  91. uni.getPrivacySetting({
  92. success: res => {
  93. console.log('是否弹出隐私==', res)
  94. if (res.needAuthorization) {
  95. this.showPrivacy = true;
  96. this.XyBottom = 0;
  97. this.name = res.privacyContractName;
  98. if (!this.userInfo.mobile) req.setStorage('isShowUpdateMobile', true)
  99. }
  100. resolve();
  101. }
  102. })
  103. })
  104. // #endif
  105. },
  106. getConfig() {
  107. req.getRequest('/api/config', {}, data => {
  108. this.config = data;
  109. req.setStorage('configRes', JSON.stringify(data));
  110. })
  111. },
  112. handleOpenPrivacyContract() {
  113. // 打开隐私协议页面
  114. uni.openPrivacyContract({
  115. success: (res) => {
  116. console.log('隐私协议打开成功==', res)
  117. }, // 打开成功
  118. fail: () => {}, // 打开失败
  119. complete: () => {}
  120. })
  121. },
  122. handleGetPhoneNumber(e) {
  123. let that = this;
  124. let sessionKey = '';
  125. app.globalData.getCheckSessoin(json => {
  126. sessionKey = json.session_key;
  127. let _params = {
  128. sessionKey: sessionKey,
  129. iv: e.detail.iv,
  130. encryptedData: e.detail.encryptedData
  131. };
  132. if (req.getStorage('pidCode')) {
  133. _params.parentId = req.getStorage('pidCode');
  134. }
  135. if (e.detail.errMsg == 'getPhoneNumber:ok') {
  136. req.postRequest('/api/weixin/mobile', _params, json => {
  137. if (json.mobile) {
  138. var userInfo = req.getStorage('userInfo');
  139. userInfo.mobile = json.mobile;
  140. req.setStorage('userInfo', userInfo);
  141. req.removeStorage('isShowUpdateMobile')
  142. }
  143. });
  144. } else {}
  145. });
  146. },
  147. exitPop() {
  148. this.showExit = true;
  149. this.XyBottom = '-100%';
  150. this.showPrivacy = false;
  151. },
  152. exit() {
  153. uni.exitMiniProgram({
  154. success: (res) => {
  155. console.log('退出小程序', res)
  156. }
  157. })
  158. },
  159. handleAgreePrivacyAuthorization() {
  160. this.XyBottom = '-100%';
  161. this.showPrivacy = false;
  162. this.showExit = false;
  163. if (this.isUpdate) this.$emit('getLocations')
  164. },
  165. jump(url) {
  166. uni.navigateTo({
  167. url: url
  168. });
  169. },
  170. }
  171. };
  172. </script>
  173. <style>
  174. @import './index.css';
  175. </style>