homeProductService.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <template>
  2. <view class="product-service" v-if="!isHide">
  3. <commonWrapper :config="dataConfig">
  4. <view class="service-list">
  5. <!-- Activity -->
  6. <view
  7. class="item"
  8. v-if="checkList.includes(0) && (couponList.length || activity.length)"
  9. >
  10. <view class="label" :style="{ color: titleColor }">{{
  11. $t("活动")
  12. }}</view>
  13. <view class="content" @click="activityTap">
  14. <view class="tags-wrapper">
  15. <!-- Coupon -->
  16. <view
  17. class="tag-item"
  18. v-if="couponList.length"
  19. :style="tagStyle"
  20. @click.stop="activityTap"
  21. >
  22. <text class="iconfont icon-ic_sale"></text>
  23. {{ $t("优惠券")
  24. }}<text
  25. class="iconfont icon-you2"
  26. :style="{ color: activityColor }"
  27. ></text>
  28. </view>
  29. <!-- Activity -->
  30. <block v-for="(item, index) in activity" :key="index">
  31. <view
  32. class="tag-item"
  33. v-if="item.type === '1'"
  34. :style="tagStyle"
  35. @click.stop="goActivity(item)"
  36. >
  37. <text class="iconfont icon-miaosha1"></text>
  38. {{ $t("秒杀")
  39. }}<text
  40. class="iconfont icon-you2"
  41. :style="{ color: activityColor }"
  42. ></text>
  43. </view>
  44. <view
  45. class="tag-item"
  46. v-if="item.type === '2'"
  47. :style="tagStyle"
  48. @click.stop="goActivity(item)"
  49. >
  50. <text class="iconfont icon-yaoqinghaoyou1"></text>
  51. {{ $t("砍价")
  52. }}<text
  53. class="iconfont icon-you2"
  54. :style="{ color: activityColor }"
  55. ></text>
  56. </view>
  57. <view
  58. class="tag-item"
  59. v-if="item.type === '3'"
  60. :style="tagStyle"
  61. @click.stop="goActivity(item)"
  62. >
  63. <text class="iconfont icon-wodetuandui"></text>
  64. {{ $t("拼团")
  65. }}<text
  66. class="iconfont icon-you2"
  67. :style="{ color: activityColor }"
  68. ></text>
  69. </view>
  70. </block>
  71. </view>
  72. <text
  73. class="iconfont icon-jiantou"
  74. :style="{ color: contentColor }"
  75. ></text>
  76. </view>
  77. </view>
  78. <!-- Selection -->
  79. <view
  80. class="item"
  81. v-if="
  82. checkList.includes(1) && attr.productAttr && attr.productAttr.length
  83. "
  84. @click="showSpecModal"
  85. >
  86. <view class="label" :style="{ color: titleColor }">{{
  87. $t("选择")
  88. }}</view>
  89. <view class="content">
  90. <view class="text line1" :style="{ color: contentColor }">
  91. {{ attrTxt }}:{{ attrValue }}
  92. </view>
  93. <text
  94. class="iconfont icon-jiantou"
  95. :style="{ color: contentColor }"
  96. ></text>
  97. </view>
  98. </view>
  99. <!-- Parameters -->
  100. <view
  101. class="item"
  102. v-if="
  103. checkList.includes(2) &&
  104. productData.params_list &&
  105. productData.params_list.length
  106. "
  107. @click="openModal('specs')"
  108. >
  109. <view class="label" :style="{ color: titleColor }">{{
  110. $t("参数")
  111. }}</view>
  112. <view class="content">
  113. <view class="text line1" :style="{ color: contentColor }">
  114. <text
  115. v-for="(item, index) in productData.params_list"
  116. :key="index"
  117. >
  118. {{ item.name }} ·
  119. </text>
  120. </view>
  121. <text
  122. class="iconfont icon-jiantou"
  123. :style="{ color: contentColor }"
  124. ></text>
  125. </view>
  126. </view>
  127. <!-- Service -->
  128. <view
  129. class="item"
  130. v-if="
  131. checkList.includes(3) &&
  132. productData.protection_list &&
  133. productData.protection_list.length
  134. "
  135. @click="openModal('protection')"
  136. >
  137. <view class="label" :style="{ color: titleColor }">{{
  138. $t("服务")
  139. }}</view>
  140. <view class="content">
  141. <view class="text line1" :style="{ color: contentColor }">
  142. <text
  143. v-for="(item, index) in productData.protection_list"
  144. :key="index"
  145. >
  146. {{ item.title }} ·
  147. </text>
  148. </view>
  149. <text
  150. class="iconfont icon-jiantou"
  151. :style="{ color: contentColor }"
  152. ></text>
  153. </view>
  154. </view>
  155. </view>
  156. </commonWrapper>
  157. </view>
  158. </template>
  159. <script>
  160. import commonWrapper from "./commonWrapper.vue";
  161. export default {
  162. name: "homeProductService",
  163. components: {
  164. commonWrapper,
  165. },
  166. props: {
  167. dataConfig: {
  168. type: Object,
  169. default: () => ({}),
  170. },
  171. productData: {
  172. type: Object,
  173. default: () => ({}),
  174. },
  175. couponList: {
  176. type: Array,
  177. default: () => [],
  178. },
  179. activity: {
  180. type: Array,
  181. default: () => [],
  182. },
  183. attr: {
  184. type: Object,
  185. default: () => ({}),
  186. },
  187. attrTxt: {
  188. type: String,
  189. default: "",
  190. },
  191. attrValue: {
  192. type: String,
  193. default: "",
  194. },
  195. },
  196. computed: {
  197. isHide() {
  198. return this.dataConfig.isHide;
  199. },
  200. checkList() {
  201. return this.dataConfig.checkBoxConfig
  202. ? this.dataConfig.checkBoxConfig.type
  203. : [];
  204. },
  205. titleColor() {
  206. return this.dataConfig.titleColor
  207. ? this.dataConfig.titleColor.color[0].item
  208. : "#999999";
  209. },
  210. contentColor() {
  211. return this.dataConfig.contentColor
  212. ? this.dataConfig.contentColor.color[0].item
  213. : "#333333";
  214. },
  215. isCustomTone() {
  216. return (
  217. this.dataConfig.toneConfig && this.dataConfig.toneConfig.tabVal === 1
  218. );
  219. },
  220. tagStyle() {
  221. if (this.isCustomTone) {
  222. const color = this.dataConfig.activityColor
  223. ? this.dataConfig.activityColor.color[0].item
  224. : "var(--view-theme)";
  225. const bg = this.dataConfig.activityBgColor
  226. ? this.dataConfig.activityBgColor.color[0].item
  227. : "var(--view-minorColorT)";
  228. return {
  229. color: color,
  230. background: bg,
  231. };
  232. }
  233. return {
  234. color: "var(--view-theme)",
  235. background: "var(--view-minorColorT)",
  236. };
  237. },
  238. activityColor() {
  239. if (this.isCustomTone) {
  240. return this.dataConfig.activityColor
  241. ? this.dataConfig.activityColor.color[0].item
  242. : "var(--view-theme)";
  243. }
  244. return "var(--view-theme)";
  245. },
  246. },
  247. methods: {
  248. activityTap() {
  249. if (this.couponList.length) {
  250. this.$emit("showCoupon");
  251. } else if (this.activity.length) {
  252. }
  253. },
  254. goActivity(item) {
  255. this.$emit("goActivity", item);
  256. },
  257. showSpecModal() {
  258. this.$emit("showSpecModal");
  259. },
  260. openModal(type) {
  261. this.$emit("openModal", type);
  262. },
  263. },
  264. };
  265. </script>
  266. <style lang="scss" scoped>
  267. .product-service {
  268. .service-list {
  269. .item {
  270. display: flex;
  271. align-items: center;
  272. padding: 28rpx 0rpx;
  273. position: relative;
  274. .label {
  275. width: 80rpx;
  276. font-size: 28rpx;
  277. margin-right: 20rpx;
  278. }
  279. .content {
  280. flex: 1;
  281. display: flex;
  282. align-items: center;
  283. justify-content: space-between;
  284. overflow: hidden;
  285. .text {
  286. font-size: 28rpx;
  287. color: #333;
  288. }
  289. .tags-wrapper {
  290. display: flex;
  291. flex-wrap: wrap;
  292. .tag-item {
  293. font-size: 24rpx;
  294. padding: 3rpx 10rpx;
  295. border-radius: 30rpx;
  296. margin-right: 10rpx;
  297. display: flex;
  298. align-items: center;
  299. .iconfont {
  300. &:first-child {
  301. font-size: 24rpx;
  302. margin-right: 5rpx;
  303. }
  304. font-size: 18rpx;
  305. line-height: 22rpx;
  306. }
  307. }
  308. }
  309. .iconfont {
  310. font-size: 24rpx;
  311. }
  312. }
  313. }
  314. }
  315. }
  316. </style>