pick-gift.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <template>
  2. <view>
  3. <view v-bind:class="['page-width', 'figure-rule', 'component-height', `${theme}-figure-rule`]">
  4. <image
  5. class="page-width component-height background-image"
  6. src="/plugins/gift/image/head-texture-background.png"
  7. ></image>
  8. <view class="page-width text-content component-height dir-left-nowrap">
  9. <view class="figure box-grow-0 dir-top-nowrap">
  10. <view class="box-grow-0 big-text text-color">表达心意新方式</view>
  11. <view class="box-grow-0 small-text text-color">
  12. ·&nbsp;网上送礼&nbsp;&nbsp;&nbsp;·&nbsp;对方填地址&nbsp;&nbsp;&nbsp;·&nbsp;支持转赠
  13. </view>
  14. </view>
  15. <view class="rule box-grow-0">
  16. <view class="identification" @click="routeRule()">
  17. 规则
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="pick-gift radius-back-color" :class="{'pick-gift-height': gift_list.length === 0}">
  23. <view
  24. v-if="gift_list.length === 0"
  25. class="selection-box radius-back-color dir-left-nowrap cross-center"
  26. @click="routeGo(`/plugins/gift/list/list`)"
  27. >
  28. <image class="gift-box" src="/plugins/gift/image/gift-box.png"></image>
  29. <view class="guided-text">
  30. <view class="big-text" :class="[`${theme}-color`]">
  31. 挑选礼物
  32. </view>
  33. <view class="small-text">
  34. 点击这里开始挑选心仪礼物
  35. </view>
  36. </view>
  37. <image class="guide" src="/static/image/icon/arrow-right.png"></image>
  38. </view>
  39. <view v-else class="page-width cart">
  40. <view class="page-width item dir-left-nowrap" v-for="(item, key) in gift_list" :key="key">
  41. <image class="pic" :src="item.pic_url"></image>
  42. <view class="content dir-top-nowrap main-left">
  43. <text class="name black t-omit">{{item.name}}</text>
  44. <view class="attr t-omit">
  45. {{item.attr_str}}
  46. </view>
  47. <view class="price-button dir-left-nowrap cross-center main-between">
  48. <text :class="[`${theme}-color`, `price`, `t-omit`]">{{item.total_cost}}</text>
  49. <view class="number-button dir-left-nowrap cross-center main-between">
  50. <button :disabled="item.number == 0" class="btn btn-left" plain @click="changeNumber(false, key)">
  51. -
  52. </button>
  53. <input @input="changeIndex(key)" @confirm="changeInput" @blur="changeInput" class="input black" v-model="item.number" type="number">
  54. <button class="btn btn-right" :class="item.number == item.attr.stock ? 'disabled' : ''" plain @click="changeNumber(true, key)" v-bind:disabled="item.number == item.attr.stock">
  55. +
  56. </button>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. <view class="page-width total-content dir-left-nowrap cross-center main-between">
  62. <text class="number">共{{gift_list | getGiftNumber}}件礼物</text>
  63. <view @click="routeGo(`/plugins/gift/list/list`)" :class="[`again`, `${theme}-background`]">继续添加</view>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. export default {
  71. name: 'pick-gift',
  72. props: {
  73. theme: String,
  74. gift_list: Array,
  75. },
  76. data() {
  77. return {
  78. index: -1,
  79. }
  80. },
  81. methods: {
  82. // 加减改变数量
  83. changeNumber(status, index) {
  84. let quantity = 0;
  85. status ? quantity = 1 : quantity = -1;
  86. this.$emit('giftNumber', {
  87. index: index, quantity: quantity, type : status
  88. });
  89. },
  90. // input改变数量
  91. changeInput(e) {
  92. this.$emit('giftInput', {
  93. index: this.index, quantity: Number(e.detail.value)
  94. });
  95. },
  96. // input获取下标
  97. changeIndex(index) {
  98. this.index = index;
  99. },
  100. // 跳转到商品列表
  101. routeGo(data) {
  102. uni.navigateTo({
  103. url: data,
  104. })
  105. },
  106. routeRule() {
  107. uni.navigateTo({
  108. url: `/pages/rules/index?url=${encodeURIComponent(this.$api.gift.config)}&key=explain`
  109. });
  110. }
  111. },
  112. filters: {
  113. getGiftNumber(data) {
  114. let number = 0;
  115. for (let i = 0; i < data.length; i++) {
  116. number += Number(data[i].number);
  117. }
  118. return number;
  119. }
  120. }
  121. }
  122. </script>
  123. <style scoped lang="scss">
  124. @import '../../css/gift.scss';
  125. .pick-gift {
  126. margin: #{0 24upx};
  127. width: calc(100% - #{48upx});
  128. position: relative;
  129. top: #{-90upx};
  130. .selection-box {
  131. width: #{702upx};
  132. height: 100%;
  133. padding: #{0 32upx};
  134. }
  135. }
  136. .pick-gift-height {
  137. height: #{150upx};
  138. }
  139. /* 礼物盒图 */
  140. .gift-box {
  141. width: #{96upx};
  142. height: #{96upx};
  143. }
  144. /* 导向图 */
  145. .guide {
  146. width: #{12upx};
  147. height: #{22upx};
  148. }
  149. /* 导向文字 */
  150. .guided-text {
  151. width: #{530upx};
  152. height: 100%;
  153. padding-left: #{24upx};
  154. .big-text {
  155. font-size: #{36upx};
  156. padding: #{34upx 0 5upx 0};
  157. }
  158. .small-text {
  159. font-size: #{24upx};
  160. color: #999999;
  161. padding: #{5upx 0 30upx 0};
  162. }
  163. }
  164. .radius-back-color {
  165. background-color: #ffffff;
  166. border-radius: #{16upx};
  167. }
  168. /*购物车*/
  169. .cart {
  170. padding: #{0 32upx 0 32upx};
  171. .total-content {
  172. height: #{100upx};
  173. /*继续添加*/
  174. .again {
  175. width: #{160upx};
  176. text-align: center;
  177. height: #{56upx};
  178. line-height: #{56upx};
  179. font-size: #{28upx};
  180. color: #ffffff;
  181. border-radius: #{32upx};
  182. }
  183. .number {
  184. font-size: #{28upx};
  185. color: #666666;
  186. }
  187. }
  188. }
  189. /*商品*/
  190. .item {
  191. padding-top: #{32upx};
  192. border-bottom: #{1upx} solid #e2e2e2;
  193. /*图片*/
  194. .pic {
  195. width: #{156upx};
  196. height: #{156upx};
  197. margin-bottom: #{32upx};
  198. }
  199. /*实质内容*/
  200. .content {
  201. width: calc(100% - #{156upx});
  202. padding-left: #{20upx};
  203. }
  204. /*标题*/
  205. .name {
  206. font-size: #{28upx};
  207. margin-top: #{2upx};
  208. }
  209. /*规格*/
  210. .attr {
  211. font-size: #{24upx};
  212. color: #999999;
  213. margin-top: #{20upx};
  214. }
  215. /*价格按钮*/
  216. .price-button {
  217. height: #{48upx};
  218. margin-top: #{34upx};
  219. .price {
  220. font-size: #{32upx};
  221. line-height: 1;
  222. width: calc(100% - #{200upx});
  223. }
  224. .price:before {
  225. content: "¥";
  226. font-size: 100%;
  227. }
  228. }
  229. .number-button {
  230. width: #{200upx};
  231. height: #{48upx};
  232. border-radius: #{8upx};
  233. border: #{1upx} solid #cdcdcd;
  234. .input {
  235. width: #{104upx};
  236. height: #{46upx};
  237. line-height: #{46upx};
  238. text-align: center;
  239. font-size: #{26upx};
  240. min-height: #{46upx};
  241. padding: 0;
  242. }
  243. .btn-left {
  244. border-right: #{1upx} solid #cdcdcd !important;
  245. }
  246. .btn-right {
  247. border-left: #{1upx} solid #cdcdcd !important;
  248. }
  249. .btn {
  250. height: #{45upx};
  251. line-height: #{45upx};
  252. width: #{45upx};
  253. font-size: #{26upx};
  254. text-align: center;
  255. color: #999999;
  256. border: none;
  257. padding: 0;
  258. border-radius: 0;
  259. background-color: transparent;
  260. margin: 0;
  261. }
  262. .disabled {
  263. background-color: #dddddd;
  264. color: #999999;
  265. }
  266. }
  267. }
  268. /* 广告图 规则 */
  269. .figure-rule {
  270. position: relative;
  271. }
  272. .text-content {
  273. position: absolute;
  274. top: 0;
  275. left: 0;
  276. }
  277. .rule {
  278. width: 12.5%;
  279. padding-top: #{40upx};
  280. .identification {
  281. width: 100%;
  282. border-top-left-radius: #{30upx};
  283. border-bottom-left-radius: #{30upx};
  284. background-color: rgba(0,0,0,.3);
  285. font-size: #{24upx};
  286. color: #ffffff;
  287. padding: #{12upx 24upx 12upx 20upx};
  288. }
  289. }
  290. .figure {
  291. width: 87.5%;
  292. padding-bottom: #{69upx};
  293. .text-color {
  294. color: #ffffff;
  295. }
  296. .big-text {
  297. font-size: #{48upx};
  298. padding: #{30upx 0 8upx 55upx};
  299. }
  300. .small-text {
  301. font-size: #{26upx};
  302. padding: #{8upx 0 52upx 48upx};
  303. }
  304. }
  305. .component-height {
  306. height: #{260upx};
  307. }
  308. </style>