good_list.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <view class="order_list" @click="listClick">
  3. <view class="header_img">
  4. <image :src="item.pic_url" mode="widthFix" class="img"></image>
  5. </view>
  6. <view class="header_title">{{ item.title }}</view>
  7. <view class="header_money red_money">
  8. <text class="symbol">{{ symbol.symbol }}</text
  9. >&nbsp;
  10. <rich-text class="_money" :nodes="Moneyhtml(item.price)"></rich-text>
  11. </view>
  12. <view class="header_money down_money" v-if="item.price != item.newprice">
  13. <trans _t="比加入时" />
  14. {{ item.newprice < item.price ? t("降") : t("涨") }}
  15. <text class="symbol">{{ symbol.symbol }}</text
  16. >&nbsp;
  17. <rich-text
  18. class="_money"
  19. :nodes="Moneyhtml(item.newprice - item.price)"
  20. v-if="item.newprice > item.price"
  21. ></rich-text>
  22. <rich-text
  23. class="_money"
  24. :nodes="Moneyhtml(item.price - item.newprice)"
  25. v-if="item.newprice < item.price"
  26. ></rich-text>
  27. </view>
  28. <view class="delete" @click.stop="deleteItem">
  29. <i class="icon-font icon-delete"></i>
  30. </view>
  31. </view>
  32. <Popup title="提醒" ref="popupRef" isClose>
  33. <template #content>
  34. <trans _t="您确定要从收藏中移除该产品吗" />
  35. </template>
  36. <template #footer>
  37. <view class="footer_btn">
  38. <view class="btn" @click="close">
  39. <trans _t="取消" />
  40. </view>
  41. <view class="btn del_btn" @click="submit">
  42. <trans _t="删除" />
  43. </view>
  44. </view>
  45. </template>
  46. </Popup>
  47. </template>
  48. <script setup>
  49. import { useSystemStore } from "@/store";
  50. import { computed } from "vue";
  51. import { Moneyhtml } from "@/utils";
  52. import Popup from "@/components/popup";
  53. import { ref, nextTick } from "vue";
  54. import { SHOP_USER_COLLECT } from "@/api";
  55. import { useCacheStore } from "@/store";
  56. const useCache = useCacheStore();
  57. const popupRef = ref(null);
  58. const useSystem = useSystemStore();
  59. const symbol = computed(() => useSystem.getSymbol);
  60. const props = defineProps({
  61. item: {
  62. type: Object,
  63. default: () => ({}),
  64. },
  65. });
  66. const listClick = () => {
  67. uni.navigateTo({
  68. url: `/pages/shop/productDetail?channel=${props.item.channel}&goods_id=${props.item.goods_id}`,
  69. });
  70. };
  71. const emit = defineEmits(["delete"]);
  72. const deleteItem = () => {
  73. popupRef.value && popupRef.value.open();
  74. };
  75. const submit = () => {
  76. setCollect({
  77. channel: props.item.channel,
  78. type: "good",
  79. goods_id: props.item.goods_id,
  80. seller_id: props.item.seller_id,
  81. title: props.item.title,
  82. pic_url: props.item.pic_url,
  83. price: props.item.price,
  84. });
  85. };
  86. const setCollect = async (params) => {
  87. try {
  88. const res = await SHOP_USER_COLLECT(params);
  89. close();
  90. nextTick(() => {
  91. useCache.changeShopCollect({
  92. channel: params.channel,
  93. goods_id: params.goods_id,
  94. isCollect: res.data.collect,
  95. });
  96. emit("delete", res);
  97. });
  98. } catch (error) {
  99. console.log(error);
  100. Toast(error.msg);
  101. }
  102. };
  103. const close = () => popupRef.value && popupRef.value.close();
  104. </script>
  105. <style lang="less" scoped>
  106. @import url("@/style.less");
  107. .order_list {
  108. background-color: var(--light);
  109. border-radius: 16rpx;
  110. margin-top: 16rpx;
  111. padding-bottom: 16rpx;
  112. position: relative;
  113. .header_img {
  114. width: 100%;
  115. aspect-ratio: 1 / 1;
  116. .img {
  117. width: inherit;
  118. height: inherit;
  119. border-radius: 16rpx;
  120. display: block;
  121. }
  122. }
  123. .header_title {
  124. color: var(--text);
  125. margin-top: 24rpx;
  126. .ellipsis(2);
  127. line-height: 48rpx;
  128. .size();
  129. padding: 0 16rpx;
  130. }
  131. .header_money {
  132. padding: 0 16rpx;
  133. font-weight: 700;
  134. .ver();
  135. margin-top: 2px;
  136. .size(32rpx);
  137. color: var(--red);
  138. line-height: 56rpx;
  139. &.down_money {
  140. .size(24rpx);
  141. }
  142. ._money {
  143. /deep/ .decimal {
  144. .size(24rpx);
  145. }
  146. }
  147. }
  148. .delete {
  149. position: absolute;
  150. top: 36rpx;
  151. right: 24rpx;
  152. background-color: var(--light);
  153. width: 50rpx;
  154. height: 50rpx;
  155. border-radius: 10rpx;
  156. .flex_center();
  157. .icon-delete {
  158. color: var(--text-01);
  159. font-size: 36rpx;
  160. }
  161. }
  162. }
  163. .footer_btn {
  164. .ver();
  165. column-gap: 24rpx;
  166. .btn {
  167. flex: 1;
  168. border-radius: 16rpx;
  169. height: 38px;
  170. padding: 16rpx 30rpx;
  171. .flex_center();
  172. border: 1px solid var(--black);
  173. font-size: calc(28rpx);
  174. color: var(--black);
  175. }
  176. .del_btn {
  177. background-color: var(--black);
  178. color: var(--light);
  179. }
  180. }
  181. </style>