Project.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <section class="project-wrap">
  3. <div class="project">
  4. <div
  5. v-show="false"
  6. @click="toProductBuilder"
  7. class="flex btn-nav">
  8. <img src="@/assets/img/builder.png" /><span>Product builder</span>
  9. </div>
  10. <!-- <div
  11. @click="handleAdd"
  12. class="flex btn-nav">
  13. <img src="@/assets/img/add.png" /><span>Add to my Project</span>
  14. </div>
  15. <div @click="openZoho" class="flex">
  16. <img src="@/assets/img/question.png" /><span>Quick Question</span>
  17. </div> -->
  18. <a
  19. href="https://zfrmz.com/2IuJGuGLCRBROyJXZetQ"
  20. target="_target"
  21. v-if="isLogin && /\@promocollection(.com.au|uk)/.test(userInfo.email)">
  22. <div class="flex btn-nav">
  23. <img src="@/assets/img/tick.png" /><span>Ticket</span>
  24. </div>
  25. </a>
  26. <a
  27. id="quickEnqriryLink"
  28. target="_blank">
  29. <div
  30. class="flex btn-nav"
  31. v-if="isLogin">
  32. <img
  33. src="@/assets/img/xunjia.png"
  34. style="opacity: 0.8"
  35. alt="" /><span>Quick Enquiry</span>
  36. </div>
  37. </a>
  38. <a
  39. target="_blank"
  40. :href="shouldButtonRecordDisabled ? 'javascript:void(0)' : `/product-record/${productInfo.product_code}?version=${productInfo.record?.version || recordData?.version}`"
  41. @click="shouldButtonRecordDisabled && $event.preventDefault()"
  42. v-show="btnShow">
  43. <div class="flex btn-nav" :class="{ disabled: shouldButtonRecordDisabled }">
  44. <img
  45. src="@/assets/img/tick.png" /><span>Item Record</span>
  46. </div>
  47. </a>
  48. </div>
  49. </section>
  50. </template>
  51. <script>
  52. export default {
  53. props: {
  54. productInfo: {
  55. type: Object,
  56. default: () => {
  57. return {}
  58. },
  59. },
  60. },
  61. data() {
  62. return {
  63. defaultURL: 'https://zfrmz.com/2IuJGuGLCRBROyJXZetQ',
  64. recordData: null
  65. }
  66. },
  67. computed: {
  68. isLogin() {
  69. return !!this.$store.state.userInfo?.email
  70. },
  71. userInfo() {
  72. return this.$store.state.userInfo || {}
  73. },
  74. btnShow() {
  75. return (
  76. this.isLogin &&
  77. /@promocollection(.com.au|.uk)/.test(this.userInfo.email)
  78. )
  79. },
  80. shouldButtonRecordDisabled() {
  81. if(this.productInfo.record && this.productInfo.record?.record_reason?.length) {
  82. return false
  83. }
  84. return !(this.recordData?.record_reason?.length)
  85. },
  86. },
  87. watch: {
  88. isLogin: {
  89. handler(newVal, oldVal) {
  90. if (newVal && newVal !== oldVal) {
  91. this.$axios.get(`/uk-api/uk/goods/detail?product_code=${this.productInfo.product_code}`).then(res => {
  92. if (res.code === 1) {
  93. this.recordData = res.result.record
  94. }
  95. })
  96. }
  97. },
  98. }
  99. },
  100. mounted() {
  101. this.generateLink()
  102. },
  103. methods: {
  104. generateLink() {
  105. const target = document.getElementById('quickEnqriryLink')
  106. const config = {
  107. name: this.userInfo.contacts,
  108. phone: this.userInfo.phone,
  109. email: this.userInfo.email,
  110. company: this.userInfo.company,
  111. product: `${this.productInfo.product_name} & ${this.productInfo.product_code}`,
  112. }
  113. let query = ''
  114. for (const key in config) {
  115. if (config[key]) {
  116. query += `&${key}=${encodeURIComponent(config[key])}`
  117. }
  118. }
  119. query = query.slice(1)
  120. target.href = this.defaultURL + '?' + query
  121. },
  122. handleAdd() {
  123. this.$emit('handleAdd')
  124. },
  125. openZoho() {
  126. document.querySelector('#zsiq_float').click()
  127. },
  128. toProductBuilder() {
  129. if (!this.$utils.checkLogin()) return
  130. this.$emit('save-selected-data')
  131. setTimeout(() => {
  132. location.href =
  133. location.origin + `/product-builder/${this.$route.params.code}`
  134. }, 0)
  135. },
  136. },
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. // $width: 100px;
  141. @media screen and (max-width: 1400px) {
  142. .btn-nav {
  143. span {
  144. display: none !important;
  145. }
  146. }
  147. }
  148. // @media screen and (min-width:1401px){
  149. // .project-wrap{
  150. // right:10px;
  151. // }
  152. // }
  153. .project-wrap {
  154. position: fixed;
  155. right: 10px;
  156. top: 172px;
  157. z-index: 1;
  158. background-color: transparent;
  159. font-size: 14px;
  160. .project {
  161. .btn-nav {
  162. text-align: center;
  163. height: 40px;
  164. border-radius: 40px;
  165. padding: 0 10px;
  166. cursor: pointer;
  167. border: none;
  168. color: #fff;
  169. margin-bottom: 15px;
  170. box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.2);
  171. background-color: #004a97;
  172. &:hover {
  173. background-color: #013269;
  174. }
  175. img {
  176. width: 20px;
  177. height: 20px;
  178. }
  179. }
  180. .disabled {
  181. background-color: #797979;
  182. cursor: not-allowed;
  183. &:hover {
  184. background-color: #797979;
  185. }
  186. }
  187. a {
  188. &:hover {
  189. div {
  190. background-color: #013269;
  191. }
  192. }
  193. span {
  194. display: inline-block;
  195. margin-left: 5px;
  196. text-align: center;
  197. flex:1;
  198. }
  199. }
  200. }
  201. }
  202. </style>