goods-file-preview.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <view class="file-preview">
  3. <view class="file" v-html="fileInfo"></view>
  4. <view class="more" @click="checkPermission">查看更多</view>
  5. <view
  6. class="cm-login"
  7. :class="{ maxBottom: !bottom && isIphoneX }"
  8. :style="{ bottom: bottom }"
  9. v-if="TipStatus && tipStatus"
  10. >
  11. <text>{{ TipStatus.text }}</text>
  12. <view class="cm-btn" @click="nextAction(TipStatus.redirect)">{{ TipStatus.btn }}</view>
  13. </view>
  14. <tui-modal
  15. :show="showModal"
  16. :content="TipStatus.text"
  17. shape="circle"
  18. :button="modalButton"
  19. :fadeIn="true"
  20. @click="handleModalClick"
  21. ></tui-modal>
  22. </view>
  23. </template>
  24. <script>
  25. import { mapState } from 'vuex'
  26. export default {
  27. data() {
  28. return {
  29. modalButton: [
  30. {
  31. text: '取消',
  32. type: 'gray',
  33. plain: true //是否空心
  34. },
  35. {
  36. text: '确认',
  37. customStyle: {
  38. color: '#fff',
  39. bgColor: 'linear-gradient(90deg, #F28F31 0%, #FF5B00 100%)'
  40. },
  41. plain: false
  42. }
  43. ],
  44. showModal: false,
  45. //用户信息相关
  46. permission: 5, //用户权限 0可查看,1未登录,2需升级会员机构,3需升级医美会员机构,4需要抵扣采美豆,5无权限查看
  47. userId: -1,
  48. archiveId: -1,
  49. fileInfo: '', // 文章预览
  50. fileName: '', // 文章标题
  51. }
  52. },
  53. computed: {
  54. ...mapState(['isIphoneX']),
  55. //资料查看状态提示
  56. TipStatus() {
  57. // 资料权限
  58. const statusText = [
  59. false, // 正常访问
  60. { text: '请登录后查看!', btn: '去登录', redirect: '/pages/login/login' },
  61. { text: '请升级成为会员机构后方可查看!', btn: '去升级', redirect: '/pages/login/apply' },
  62. { text: '请升级成为医美会员机构后方可查看!', btn: '去升级', redirect: '/pages/login/apply' },
  63. { text: '需抵扣100采美豆方可查看!', btn: '去查看', redirect: 10 },
  64. { text: '无权限查看!', btn: '确认' }
  65. ]
  66. // 0可查看,1未登录,2需升级会员机构,3需升级医美会员机构,4需要抵扣采美豆,5无权限查看
  67. return statusText[this.permission]
  68. }
  69. },
  70. watch: {
  71. TipStatus(val) {
  72. if(this.TipStatus) {
  73. this.timer = setTimeout(()=>{
  74. this.tipStatus = false
  75. clearTimeout(this.timer)
  76. }, 10000)
  77. }
  78. this.$emit('tipStatus', this.TipStatus)
  79. }
  80. },
  81. mounted() {
  82. this.fileInfo = uni.getStorageSync('fileInfo')
  83. },
  84. onLoad(options) {
  85. this.userId = options.userId
  86. this.archiveId = options.archiveId
  87. this.permission = options.permission
  88. this.fileName = options.fileName
  89. uni.setNavigationBarTitle({
  90. title: this.fileName
  91. })
  92. },
  93. methods: {
  94. //用户权限校验拦截
  95. checkPermission() {
  96. //permission:查看权限:0可查看,1未登录,2需升级会员机构,3需升级医美会员机构,4需要抵扣采美豆,5无权限查看
  97. const _self = this
  98. // 如果 TipStatus 返回false 就放行
  99. if (!_self.TipStatus) return 0
  100. this.modalButton[1].text = this.TipStatus.btn
  101. this.showModal = true
  102. return -1
  103. },
  104. // 点击按钮后要做的事
  105. nextAction(redirect) {
  106. const _self = this
  107. if (typeof redirect == 'string') {
  108. // 跳转链接
  109. this.$api.navigateTo(redirect)
  110. }
  111. if (redirect === 10) {
  112. this.searchArchiveByBean()
  113. }
  114. },
  115. // modal 按钮点击
  116. handleModalClick(e) {
  117. // 点击确认按钮
  118. if (e.index === 1) {
  119. this.showModal = false
  120. this.nextAction(this.TipStatus.redirect) //执行下一步
  121. } else {
  122. this.showModal = false
  123. }
  124. },
  125. //采美豆抵扣
  126. searchArchiveByBean() {
  127. this.BeautyArchive.SearchArchiveByBeans({
  128. userId: this.userId,
  129. archiveId: this.archiveId
  130. })
  131. .then(res => {
  132. uni.showToast({
  133. duration: 1500,
  134. title: res.msg
  135. })
  136. setTimeout(() => {
  137. //刷新资料列表
  138. this.getDetail()
  139. }, 1500)
  140. })
  141. .catch(err => {
  142. uni.showToast({
  143. icon: 'none',
  144. duration: 1500,
  145. title: err.msg
  146. })
  147. })
  148. },
  149. }
  150. }
  151. </script>
  152. <style lang="scss">
  153. page {
  154. background-color: #ccc;
  155. }
  156. .file-preview {
  157. position: relative;
  158. padding-bottom: 5%;
  159. .file {
  160. width: 90%;
  161. min-height: 600rpx;
  162. margin: 5% auto 0 auto;
  163. background: #fff;
  164. position: relative;
  165. }
  166. .file::after {
  167. content: ' ';
  168. position: absolute;
  169. left: 0;
  170. bottom: 0;
  171. box-shadow: 0 -8px 15px red;
  172. width: 100%;
  173. height: 6rpx;
  174. }
  175. .more {
  176. color: red;
  177. position: absolute;
  178. bottom: 0;
  179. left: 50%;
  180. transform: translate(-50%, -100%);
  181. background: rgba(255, 255, 255, 0.8);
  182. width: 90%;
  183. text-align: center;
  184. }
  185. }
  186. .cm-login {
  187. position: fixed;
  188. left: 24rpx;
  189. bottom: 115rpx; // 包含商品导航
  190. display: flex;
  191. justify-content: space-between;
  192. align-items: center;
  193. padding: 0 32rpx;
  194. width: 702rpx;
  195. height: 90rpx;
  196. background: #ffe6dc;
  197. border-radius: 16px;
  198. box-sizing: border-box;
  199. z-index: 9;
  200. &.maxBottom {
  201. bottom: -100rpx;
  202. z-index: 999;
  203. animation: permiMove .3s ease-in-out;
  204. animation-fill-mode: forwards;
  205. }
  206. text {
  207. font-size: 26rpx;
  208. color: #FF5B00;
  209. }
  210. .cm-btn {
  211. width: 136rpx;
  212. height: 48rpx;
  213. background: #FF5B00;
  214. border-radius: 28px;
  215. font-size: 26rpx;
  216. text-align: center;
  217. line-height: 48rpx;
  218. color: #ffffff;
  219. }
  220. }
  221. </style>