Project.vue 5.6 KB

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