lyg-popup.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template name="protocol-popup">
  2. <view @touchmove.stop.prevent="clear" v-show="showPopup">
  3. <view class="popup_mask" @touchmove.stop.prevent="clear"></view>
  4. <view class="popup_content">
  5. <view class="title">{{title}}</view>
  6. <view class="explain_text">
  7. 请你务必认真阅读、充分理解“服务协议”和“隐私政策”各条款,包括但不限于:为了向你提供数据、分享等服务所要获取的权限信息。
  8. <view class="line">你可以阅读<navigator :url="protocolPath" class="path" hover-class="navigator-hover">《服务协议》
  9. </navigator>和<navigator :url="policyPath" class="path" hover-class="navigator-hover">《隐私政策》
  10. </navigator>了解详细信息。如您同意,请点击"同意"开始接受我们的服务。
  11. </view>
  12. </view>
  13. <view class="button">
  14. <view @tap="back">暂不使用</view>
  15. <view @tap="confirm">同意</view>
  16. </view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. name: "lyg-popup",
  23. props: {
  24. title: {
  25. type: String,
  26. default: "服务协议和隐私政策"
  27. },
  28. // 协议路径
  29. protocolPath: {
  30. type: String
  31. },
  32. // 政策路径
  33. policyPath: {
  34. type: String
  35. },
  36. policyStorageKey: {
  37. type: String,
  38. default: "has_read_privacy"
  39. }
  40. },
  41. data() {
  42. return {
  43. showPopup: false
  44. };
  45. },
  46. created: function() {
  47. var that = this;
  48. console.log("lyg-popup created");
  49. uni.getStorage({
  50. key: this.policyStorageKey,
  51. success: (res) => {
  52. if (res.data) {
  53. that.showPopup = false;
  54. uni.showTabBar({});
  55. }
  56. },
  57. fail: function(e) {
  58. that.showPopup = true;
  59. uni.hideTabBar({});
  60. console.log(e)
  61. }
  62. });
  63. },
  64. methods: {
  65. // 禁止滚动
  66. clear() {
  67. return;
  68. },
  69. back() {
  70. this.$emit('popupState', false)
  71. // #ifdef APP-PLUS
  72. if (uni.getSystemInfoSync().platform == 'ios') {
  73. const threadClass = plus.ios.importClass("NSThread");
  74. const mainThread = plus.ios.invoke(threadClass, "mainThread");
  75. // plus.ios.invoke(mainThread, "exit");
  76. //上面的不起效果下面的
  77. plus.ios.import("UIApplication").sharedApplication().performSelector("exit")
  78. } else if (uni.getSystemInfoSync().platform == 'android') {
  79. plus.runtime.quit();
  80. }
  81. // #endif
  82. },
  83. // 关闭弹框
  84. confirm() {
  85. this.showPopup = false;
  86. this.$emit('popupState', true);
  87. uni.setStorage({
  88. key: this.policyStorageKey,
  89. data: true
  90. });
  91. uni.showTabBar({});
  92. }
  93. }
  94. };
  95. </script>
  96. <style lang="scss">
  97. .popup_mask {
  98. position: fixed;
  99. bottom: 0;
  100. top: 0;
  101. left: 0;
  102. right: 0;
  103. background-color: rgba(0, 0, 0, 0.4);
  104. transition-property: opacity;
  105. transition-duration: 0.3s;
  106. opacity: 0;
  107. z-index: 98;
  108. }
  109. .popup_mask {
  110. opacity: 1;
  111. }
  112. .popup_content {
  113. overflow: hidden;
  114. box-sizing: border-box;
  115. padding: 40upx 20upx 0 20upx;
  116. position: fixed;
  117. bottom: 30%;
  118. border-radius: 8px;
  119. left: 50%;
  120. margin-left: -40%;
  121. right: 0;
  122. min-height: 400upx;
  123. background: #ffffff;
  124. width: 80%;
  125. z-index: 99;
  126. .title {
  127. text-align: center;
  128. font-size: 34upx;
  129. padding: 10upx 0 0 0;
  130. }
  131. .explain_text {
  132. font-size: 30upx;
  133. padding: 30upx 30upx 40upx 30upx;
  134. line-height: 38upx;
  135. .line {
  136. display: block;
  137. .path {
  138. color: #007aff;
  139. display: inline-block;
  140. text-align: center;
  141. }
  142. }
  143. }
  144. .button {
  145. display: flex;
  146. padding: 20upx;
  147. align-items: center;
  148. font-size: 34upx;
  149. justify-content: space-around;
  150. border-top: 1upx solid #f2f2f2;
  151. view {
  152. text-align: center;
  153. }
  154. }
  155. }
  156. </style>