Project.vue 5.3 KB

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