cm-product-modal.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template name="cm-product-modal">
  2. <!-- 商品详情可见度弹窗提醒 -->
  3. <view>
  4. <tui-modal
  5. :show="showModal"
  6. @click="handleClick"
  7. @cancel="hideMobel"
  8. :content="contentModalText"
  9. :button="modalButton"
  10. color="#333"
  11. :size="32"
  12. shape="circle"
  13. :maskClosable="false"
  14. >
  15. </tui-modal>
  16. </view>
  17. </template>
  18. <script>
  19. import { mapState } from 'vuex'
  20. export default {
  21. name: 'cm-product-modal',
  22. props: {
  23. showModal: {
  24. type: Boolean,
  25. default: false
  26. },
  27. commodityDetailsFlag: {
  28. type: Number
  29. },
  30. userIdentity: {
  31. type: Number
  32. },
  33. firstClubType: {
  34. type: Number
  35. },
  36. isShareType:{
  37. type:String
  38. }
  39. },
  40. data() {
  41. return {
  42. contentModalText: '',
  43. modalButton: [],
  44. }
  45. },
  46. computed: {
  47. ...mapState(['hasLogin'])
  48. },
  49. created() {
  50. // 根据商品详情可见度显示弹窗 product.commodityDetailsFlag 1.所有人可见 2.所有机构可见 3.仅会员机构可见 4.仅医美机构可见
  51. this.initModal(this.commodityDetailsFlag, this.userIdentity, this.firstClubType)
  52. },
  53. methods: {
  54. initModal(flag, identity, clubType) {
  55. this.contentModalText = this.setModalText(flag, identity, clubType, this.hasLogin)
  56. this.modalButton = this.setModalButton(flag, identity, clubType, this.hasLogin)
  57. },
  58. setModalText(flag = '', identity = '', clubType = '', hasLogin) {
  59. const map = {
  60. '2': '该商品仅限已注册机构查看,请注册机构账户后继续查看。有采美账号的,请直接登录',
  61. '3': '该商品仅限资质机构查看,请注册资质机构后继续查看。有采美账号的,请直接登录。',
  62. '4': '该商品仅限医美类机构查看,请注册医美机构后继续查看。有采美账号的,请直接登录。',
  63. '34': '该商品仅限资质机构查看,请升级为资质机构后继续查看。',
  64. '44': '该商品仅限医美类机构查看,请升级为医美机构后继续查看。',
  65. '42': '该商品仅限医美类机构查看,您暂无权限。您可去机构资料页面查看机构类型。'
  66. }
  67. // 游客提示语
  68. if (!hasLogin) {
  69. return map[flag]
  70. }
  71. const code = flag === 4 && identity === 2 && clubType !== 1 ? '42' : `${flag}${identity}`
  72. return map[code]
  73. },
  74. setModalButton(flag = '', identity = '', clubType = '', hasLogin) {
  75. const customStyle = { color: '#fff', bgColor: 'linear-gradient(90deg, #F28F31 0%, #FF5B00 100%)' }
  76. const btnMap = {
  77. '22': [
  78. { text: '关闭', type: 'gray', plain: true },
  79. {
  80. text: '去注册/登录',
  81. customStyle: customStyle,
  82. plain: false
  83. }
  84. ],
  85. '34': [
  86. { text: '关闭', type: 'gray', plain: true },
  87. {
  88. text: '去升级',
  89. customStyle: customStyle,
  90. plain: false
  91. }
  92. ],
  93. '44': [
  94. { text: '关闭', type: 'gray', plain: true },
  95. {
  96. text: '去升级',
  97. customStyle: customStyle,
  98. plain: false
  99. }
  100. ],
  101. '42': [
  102. { text: '关闭', type: 'gray', plain: true },
  103. {
  104. text: '去查看资料',
  105. customStyle: customStyle,
  106. plain: false
  107. }
  108. ]
  109. }
  110. if (!hasLogin) {
  111. // 游客按钮
  112. return btnMap['22']
  113. }
  114. const code = flag === 4 && identity === 2 && clubType !== 1 ? '42' : `${flag}${identity}`
  115. console.log('code',code)
  116. return btnMap[code]
  117. },
  118. handleClick(e) {
  119. // 医美
  120. if (e.index == 1) {
  121. if (!this.hasLogin) {
  122. //游客跳转登录页
  123. this.$api.navigateTo('/pages/login/login')
  124. } else {
  125. if (this.userIdentity === 4) {
  126. // 个人机构跳转升级页面
  127. this.$api.navigateTo('/pages/login/apply')
  128. } else if (this.userIdentity === 2) {
  129. //会员机构
  130. if (this.firstClubType != 1) {
  131. // 会员非医美机构跳转资料页
  132. this.$api.navigateTo('/pages/login/information')
  133. }
  134. }
  135. }
  136. this.$parent.showModal = false
  137. } else {
  138. this.$parent.showModal = false
  139. if (this.isShareType == 'share') {
  140. this.$api.switchTabTo('/pages/tabBar/home/index')
  141. } else {
  142. this.$api.navigateBack(1)
  143. }
  144. }
  145. },
  146. hideMobel() {
  147. this.$parent.showModal = false
  148. }
  149. }
  150. }
  151. </script>
  152. <style lang="scss"></style>