setMealItem.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <div class="set-meal-item">
  3. <div class="set-meal-item-title">
  4. {{ packageType[data.cloudSetMealType] }} 安卓{{ data.androidVersion }}
  5. </div>
  6. <img :src="IMG_URL + '/' + data.promotionalImages" alt="" />
  7. <div :class="['set-meal-item_content', { 'expand-open': isExpand }]">
  8. <div
  9. v-for="item in data.mealList"
  10. :key="item.id"
  11. class="set-meal-item_content-item"
  12. >
  13. <div class="set-meal-item_content-item_left">
  14. <div v-if="!type" class="invited">
  15. <img :src="require(`@/assets/image/${item.phoneType}_icon.png`)" />
  16. <div class="invited-info">
  17. <div>{{ packageType[item.phoneType] }}{{ item.day }}天套餐</div>
  18. <div>
  19. <div class="actual-price">
  20. <span>¥</span>{{ item.actualPrice }}
  21. </div>
  22. <div v-if="item.originalPrice" class="original-price">
  23. <span>¥</span>{{ item.originalPrice }}
  24. </div>
  25. <div class="difference" v-if="item.originalPrice && item.actualPrice">
  26. 免单 {{ difference(item) }} 元
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. <div v-else>
  32. {{ packageType[item.phoneType] }}{{ item.day }}天套餐
  33. </div>
  34. </div>
  35. <div class="set-meal-item_content-item_right">
  36. <div class="set-meal-item_content-item_right-price" v-if="type">
  37. <span>¥</span
  38. >{{ item.originalPrice ? item.originalPrice : item.actualPrice }}
  39. </div>
  40. <div @click="add(item)" :class="{ mark: type }">
  41. {{ type ? '0元领' : '新增云手机' }}
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. <div class="expand" v-if="data.mealList.length > 2">
  47. <span @click="isExpand = !isExpand">
  48. {{ isExpand ? '收起' : '查看全部' }}
  49. <van-icon :name="isExpand ? 'arrow-up' : 'arrow-down'" />
  50. </span>
  51. </div>
  52. </div>
  53. </template>
  54. <script>
  55. import BigNumber from "bignumber.js";
  56. export default {
  57. name: 'setMealItem',
  58. props: {
  59. type: {
  60. type: Number,
  61. default: 1, // 0是被邀请人 1是邀请人
  62. },
  63. data: {
  64. type: Object,
  65. default: () => {
  66. return {};
  67. },
  68. },
  69. },
  70. data() {
  71. return {
  72. isExpand: false,
  73. packageType: {
  74. VIP: '星动',
  75. SVIP: '星曜',
  76. STARRYSKY: '星空',
  77. STAR: '唔即',
  78. STARPRO: '唔即Pro',
  79. },
  80. IMG_URL: process.env.IMG_URL,
  81. };
  82. },
  83. mounted() {},
  84. methods: {
  85. add(data) {
  86. if (this.type) {
  87. this.$axios
  88. .$get('activity/v5/assist/bargaining/current/bargainingStatus', {
  89. params: {
  90. operateActivityId: localStorage.getItem('auth.operateActivityId'),
  91. },
  92. })
  93. .then((res) => {
  94. if (res.success) {
  95. if (!res.data.bargainingStatus) {
  96. let url = '/claimCloudPhone/type?type=1&menuRuleId=' + data.id;
  97. if (this.$route.query.userCardId) {
  98. url += `&userCardId=${this.$route.query.userCardId}`;
  99. }
  100. this.$router.push(url);
  101. } else {
  102. if (res.data.bargainingStatus === 6) {
  103. setTimeout(() => {
  104. this.$toast('活动已到期');
  105. });
  106. return;
  107. }
  108. setTimeout(() => {
  109. this.$toast('已参加正在砍价活动,请退出后重新进入');
  110. });
  111. }
  112. }
  113. })
  114. .finally(() => {
  115. this.$toast.clear();
  116. });
  117. return;
  118. }
  119. this.$emit('buy', data);
  120. },
  121. difference({originalPrice, actualPrice}) {
  122. return +new BigNumber(originalPrice).minus(new BigNumber(actualPrice));
  123. },
  124. },
  125. computed: {
  126. list() {
  127. this.data.mealList.length > 10
  128. ? this.data.mealList.slice(0, 9)
  129. : this.data.mealList;
  130. },
  131. },
  132. };
  133. </script>
  134. <style lang="less" scoped>
  135. .set-meal-item {
  136. background: #ffffff;
  137. border-radius: 14px;
  138. border: 1px solid #feffef;
  139. margin-top: 12px;
  140. padding: 16px;
  141. font-family: PingFangSC, PingFang SC;
  142. & > img {
  143. height: 59px;
  144. width: 100%;
  145. margin-top: 12px;
  146. }
  147. .set-meal-item_content {
  148. max-height: 142px;
  149. overflow: hidden;
  150. &.expand-open {
  151. max-height: none;
  152. }
  153. .set-meal-item_content-item {
  154. padding: 14px 0;
  155. border-bottom: 1px solid #f0f0f0;
  156. display: flex;
  157. justify-content: space-between;
  158. .set-meal-item_content-item_left {
  159. display: flex;
  160. align-items: center;
  161. font-family: PingFangSC, PingFang SC;
  162. font-weight: 500;
  163. font-size: 14px;
  164. color: #6d2b12;
  165. line-height: 20px;
  166. text-align: left;
  167. font-style: normal;
  168. .invited {
  169. display: flex;
  170. align-items: center;
  171. & > img {
  172. width: 36px;
  173. height: 36px;
  174. }
  175. .invited-info {
  176. margin-left: 8px;
  177. & > div:last-of-type {
  178. display: flex;
  179. & > div {
  180. font-weight: bold;
  181. line-height: 20px;
  182. font-style: normal;
  183. }
  184. .actual-price {
  185. font-size: 16px;
  186. color: #f04646;
  187. }
  188. .original-price {
  189. font-size: 12px;
  190. color: #bbbbbb;
  191. line-height: 23px;
  192. text-decoration: line-through;
  193. margin-left: 8px;
  194. }
  195. }
  196. }
  197. }
  198. }
  199. .set-meal-item_content-item_right {
  200. display: flex;
  201. align-items: center;
  202. .set-meal-item_content-item_right-price {
  203. font-weight: bold;
  204. font-size: 16px;
  205. color: #f04646;
  206. line-height: 20px;
  207. text-align: left;
  208. font-style: normal;
  209. display: flex;
  210. align-items: center;
  211. margin-right: 5px;
  212. text-decoration: line-through;
  213. font-family: AlibabaPuHuiTi, AlibabaPuHuiTi;
  214. font-weight: bold;
  215. }
  216. & > div:last-of-type {
  217. height: 30px;
  218. padding: 6px 12px;
  219. background: linear-gradient(178deg, #fd8c50 0%, #fc3307 100%);
  220. border-radius: 21px;
  221. font-weight: bold;
  222. font-size: 14px;
  223. color: #ffffff;
  224. line-height: 18px;
  225. text-align: left;
  226. font-style: normal;
  227. &.mark {
  228. height: 42px;
  229. line-height: 42px;
  230. font-size: 24px;
  231. padding: 0 32px;
  232. }
  233. }
  234. }
  235. }
  236. }
  237. .set-meal-item-title {
  238. font-family: PingFangSC, PingFang SC;
  239. font-weight: 500;
  240. font-size: 18px;
  241. color: #6d2b12;
  242. line-height: 20px;
  243. text-align: left;
  244. font-style: normal;
  245. }
  246. .expand {
  247. display: flex;
  248. justify-content: center;
  249. font-weight: 400;
  250. font-size: 12px;
  251. color: #7d6156;
  252. line-height: 16px;
  253. text-align: center;
  254. font-style: normal;
  255. margin-top: 10px;
  256. }
  257. .difference {
  258. font-family: AlibabaPuHuiTi, AlibabaPuHuiTi;
  259. display: flex;
  260. justify-content: center;
  261. align-items: center;
  262. font-weight: 500;
  263. font-size: 12px;
  264. color: #f04646;
  265. line-height: 16px;
  266. text-align: left;
  267. font-style: normal;
  268. margin-left: 4px;
  269. }
  270. }
  271. </style>