index.vue 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364
  1. <template>
  2. <view class="goods-sku-popup" catchtouchmove="true" :class="getValue() && complete ? 'show' : 'none'"
  3. @touchmove.stop.prevent="moveHandle" @click.stop="stop">
  4. <!-- 页面内容开始 -->
  5. <view class="mask" @click="close('mask')"></view>
  6. <view class="layer attr-content" :style="{
  7. borderRadius: borderRadius + 'rpx ' + borderRadius + 'rpx 0 0'
  8. }">
  9. <view class="specification-wrapper">
  10. <scroll-view class="specification-wrapper-content" scroll-y="true">
  11. <view class="specification-header">
  12. <view class="specification-left">
  13. <image class="product-img" :src="selectShop.image ? selectShop.image : goodsInfo[goodsThumbName]" :style="{
  14. backgroundColor: goodsThumbBackgroundColor
  15. }" mode="aspectFill" @click="previewImage"></image>
  16. </view>
  17. <view class="specification-right">
  18. <view class="price-content" :style="{
  19. color: themeColorFn('priceColor')
  20. }">
  21. <text class="sign">¥</text>
  22. <text class="price" :class="priceCom.length > 16 ? 'price2' : ''">
  23. {{ priceCom }}
  24. </text>
  25. </view>
  26. <view class="inventory" v-if="!hideStock">{{ stockText }}:{{ stockCom }}</view>
  27. <view class="inventory" v-else></view>
  28. <view class="choose" v-show="isManyCom">
  29. <text v-if="!selectArr.every(val => val == '')">已选:{{ selectArr.join(' ') }}</text>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="specification-content">
  34. <view v-show="isManyCom" class="specification-item" v-for="(item, index1) in goodsInfo[specListName]"
  35. :key="index1">
  36. <view class="item-title">{{ item.name }}</view>
  37. <view class="item-wrapper">
  38. <view class="item-content" v-for="(item_value, index2) in item.list" :key="index2" :class="[
  39. item_value.ishow ? '' : 'noactived',
  40. subIndex[index1] == index2 ? 'actived' : ''
  41. ]" :style="[
  42. item_value.ishow ? '' : themeColorFn('disableStyle'),
  43. item_value.ishow ? themeColorFn('btnStyle') : '',
  44. subIndex[index1] == index2 ? themeColorFn('activedStyle') : ''
  45. ]" @click="skuClick(item_value, index1, index2)">
  46. {{ item_value.name }}
  47. </view>
  48. </view>
  49. </view>
  50. <view class="number-box-view">
  51. <view style="flex: 1;">数量</view>
  52. <view style="flex: 4;text-align: right;">
  53. <number-box v-model="selectNum" :min="minBuyNum || 1" :max="maxBuyNumCom" :step="stepBuyNum || 1"
  54. :step-strictly="stepStrictly" :positive-integer="true">
  55. </number-box>
  56. </view>
  57. </view>
  58. </view>
  59. </scroll-view>
  60. <view class="close" @click="close('close')" v-if="showClose != false">
  61. <image class="close-item" :src="closeImage"></image>
  62. </view>
  63. </view>
  64. <view class="btn-wrapper" v-if="outFoStock || mode == 4">
  65. <view class="sure" style="color:#ffffff;background-color:#cccccc">{{ noStockText }}</view>
  66. </view>
  67. <view class="btn-wrapper" v-else-if="mode == 1">
  68. <view class="sure add-cart" style="border-radius:38rpx 0rpx 0rpx 38rpx;" @click="addCart" :style="{
  69. color: themeColorFn('addCartColor'),
  70. backgroundColor: themeColorFn('addCartBackgroundColor')
  71. }">
  72. {{ addCartText }}
  73. </view>
  74. <view class="sure" style="border-radius:0rpx 38rpx 38rpx 0rpx;" @click="buyNow" :style="{
  75. color: themeColorFn('buyNowColor'),
  76. backgroundColor: themeColorFn('buyNowBackgroundColor')
  77. }">
  78. {{ buyNowText }}
  79. </view>
  80. </view>
  81. <view class="btn-wrapper" v-else-if="mode == 2">
  82. <view class="sure add-cart" @click="addCart" :style="{
  83. color: themeColorFn('addCartColor'),
  84. backgroundColor: themeColorFn('addCartBackgroundColor')
  85. }">
  86. {{ addCartText }}
  87. </view>
  88. </view>
  89. <view class="btn-wrapper" v-else-if="mode == 3">
  90. <view class="sure" @click="buyNow" :style="{
  91. color: themeColorFn('buyNowColor'),
  92. backgroundColor: themeColorFn('buyNowBackgroundColor')
  93. }">
  94. {{ buyNowText }}
  95. </view>
  96. </view>
  97. </view>
  98. <!-- 页面内容结束 -->
  99. </view>
  100. </template>
  101. <script>
  102. import NumberBox from './number-box'
  103. var vk; // vk依赖
  104. var goodsCache = {}; // 本地商品缓存
  105. export default {
  106. name: "GoodsSkuPopup",
  107. components: {
  108. NumberBox
  109. },
  110. emits: ["update:modelValue", "input", "update-goods", "open", "close", "add-cart", "buy-now"],
  111. props: {
  112. // true 组件显示 false 组件隐藏
  113. value: {
  114. Type: Boolean,
  115. default: false
  116. },
  117. modelValue: {
  118. Type: Boolean,
  119. default: false
  120. },
  121. // vk云函数路由模式参数开始-----------------------------------------------------------
  122. // 商品id
  123. goodsId: {
  124. Type: String,
  125. default: ""
  126. },
  127. // vk路由模式框架下的云函数地址
  128. action: {
  129. Type: String,
  130. default: ""
  131. },
  132. // vk云函数路由模式参数结束-----------------------------------------------------------
  133. // 该商品已抢完时的按钮文字
  134. noStockText: {
  135. Type: String,
  136. default: "该商品已抢完"
  137. },
  138. // 库存文字
  139. stockText: {
  140. Type: String,
  141. default: "库存"
  142. },
  143. // 商品表id的字段名
  144. goodsIdName: {
  145. Type: String,
  146. default: "_id"
  147. },
  148. // sku表id的字段名
  149. skuIdName: {
  150. Type: String,
  151. default: "_id"
  152. },
  153. // sku_list的字段名
  154. skuListName: {
  155. Type: String,
  156. default: "sku_list"
  157. },
  158. // spec_list的字段名
  159. specListName: {
  160. Type: String,
  161. default: "spec_list"
  162. },
  163. // 库存的字段名 默认 stock
  164. stockName: {
  165. Type: String,
  166. default: "stock"
  167. },
  168. // sku组合路径的字段名
  169. skuArrName: {
  170. Type: String,
  171. default: "sku_name_arr"
  172. },
  173. // 默认单规格时的规格组名称
  174. defaultSingleSkuName: {
  175. Type: String,
  176. default: "默认"
  177. },
  178. // 模式 1:都显示 2:只显示购物车 3:只显示立即购买 4:显示缺货按钮 默认 1
  179. mode: {
  180. Type: Number,
  181. default: 1
  182. },
  183. // 点击遮罩是否关闭组件 true 关闭 false 不关闭 默认true
  184. maskCloseAble: {
  185. Type: Boolean,
  186. default: true
  187. },
  188. // 顶部圆角值
  189. borderRadius: {
  190. Type: [String, Number],
  191. default: 0
  192. },
  193. // 商品缩略图字段名(未选择sku时)
  194. goodsThumbName: {
  195. Type: [String],
  196. default: "goods_thumb"
  197. },
  198. // 商品缩略图背景颜色,如#999999
  199. goodsThumbBackgroundColor: {
  200. Type: String,
  201. default: "#999999"
  202. },
  203. // 最小购买数量 默认 1
  204. minBuyNum: {
  205. Type: [Number, String],
  206. default: 1
  207. },
  208. // 最大购买数量 默认 100000
  209. maxBuyNum: {
  210. Type: [Number, String],
  211. default: 100000
  212. },
  213. // 步进器步长 默认 1
  214. stepBuyNum: {
  215. Type: [Number, String],
  216. default: 1
  217. },
  218. // 是否只能输入 step 的倍数
  219. stepStrictly: {
  220. Type: Boolean,
  221. default: false
  222. },
  223. // 自定义获取商品信息的函数,支付宝小程序不支持该属性,请使用localdata属性
  224. customAction: {
  225. Type: [Function],
  226. default: null
  227. },
  228. // 本地数据源
  229. localdata: {
  230. type: Object
  231. },
  232. // 价格的字体颜色
  233. priceColor: {
  234. Type: String
  235. },
  236. // 立即购买按钮的文字
  237. buyNowText: {
  238. Type: String,
  239. default: "立即购买"
  240. },
  241. // 立即购买按钮的字体颜色
  242. buyNowColor: {
  243. Type: String
  244. },
  245. // 立即购买按钮的背景颜色
  246. buyNowBackgroundColor: {
  247. Type: String
  248. },
  249. // 加入购物车按钮的文字
  250. addCartText: {
  251. Type: String,
  252. default: "加入购物车"
  253. },
  254. // 加入购物车按钮的字体颜色
  255. addCartColor: {
  256. Type: String
  257. },
  258. // 加入购物车按钮的背景颜色
  259. addCartBackgroundColor: {
  260. Type: String
  261. },
  262. // 不可点击时,按钮的样式
  263. disableStyle: {
  264. Type: Object,
  265. default: null
  266. },
  267. // 按钮点击时的样式
  268. activedStyle: {
  269. Type: Object,
  270. default: null
  271. },
  272. // 按钮常态的样式
  273. btnStyle: {
  274. Type: Object,
  275. default: null
  276. },
  277. // 是否显示右上角关闭按钮
  278. showClose: {
  279. Type: Boolean,
  280. default: true
  281. },
  282. // 关闭按钮的图片地址 https://img.alicdn.com/imgextra/i1/121022687/O1CN01ImN0O11VigqwzpLiK_!!121022687.png
  283. closeImage: {
  284. Type: String,
  285. default: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAEyUlEQVR42sSZeWwNURTGp4OqtBo7sSXELragdkpQsRRJ1Zr4hyJiJ9YgxNIg1qANiT+E1i5IY0kVVWtQEbuEKLFGUSH27/ANN5PXmTvzupzkl/tm8t6b7517lnvvC0lKSjJ8WmnQAUSDFqABqALKgl8gD7wE90E2SAeXwFf1SxISErQeVtKHwCgwFsSDSIf3hYFKoCkYDBaDdyAViHdueHmoF6FtwDLQ23b/E7gM7oIcejIERIDaoBFoC8qA8mA8SQNz6W1XC9GY+nCQCCYAk/c+gF0gBZwH312+IxR0BCPBUIaH2A+wHsxHCHxx+gLT5QGN6a2JfG8uvVCDws9oiDQYlxkMGfHyQvARlADTwcXk5OT6foV2kS8ATXidymlcyen1a/Jjl9IJh3hPkjELYqO8Cu0KjjNZvtETw5jFBWXPmGSTGQKSeOn5iQ0kVLL0CINfPNcPbDMKyRCbGzEMBJ+ZD8cChYFdqGTqfsWT8otPGoVsEHsMwxDFs3shNsxJ6BrQ0Po8OGUUkVHsNCVml+cntB1jUWwn2GEUsTEMrASbDK+2CCQ0kYX6nfLLisMmKqUr0S60M+jG10vAm+JSCa8+x7CKlzHwaktV6DiObzUzPJIxFO1BQ12wGtTReO9GetVgY/kjNJzZbcWmTjHfxw51AsRqvL8eOAtmsJuFu3g1l+1ZLB5eDTVZ3K0P7tL0TkWOpSg61kVkBtuuNRthGs+wtJST5aQI7cEbkkRXNYVKgX6kIdYuUhYzMQwxN8tiExCLFqHNeSF9/aem0BzGp5PYQCJ7c/Gsk1RfuSD6U1dNpcDf9ZigTmKbMRZ9iVTsHscGJluW2FMf1SSQWGnBmaB6kCJVTVVNJZE++Cx9drEllS1KMCINpURFmEbBWA63Fz9s95cGIdJgp/zXmT4pZcOvSUzuZttTbblmnc3PIjjmidDXvKgdhMh0JdbzuCjWrbNOVovjS5P7bkPJ/mBESkz2BO0166ybNeJ431S2q+01NntuIq3E0amzjiZtk9tssWyTDzO4525bACK9NAUn68TtkNhpEXpOSagRml+S6iLSSeweHv242Qhl13rRyvoDvDlKyTQny/ZQJ+1iH7vVbEx7OR5UiKVIO7VicgvHCtwrudloMIV7/0uadVYW57O4Wvvi8v4pymlKkrpwvsDeLLZAY2pkwbAB3PSQfC+4cH7l4k1ZH8zkZRq8ecO+Z5rN40JJqnXFuGfaxPCTLjcn0OZOpnArXw8HY4paIbw5CcMgXq6HN2/mt6+XGLrN15tBryIUGavMpCTrfKcDCKkAceA9S8nhAOehhSUyhXpkBxxnP4YM1InugP7cBkjBPcqVUWFYCEROxXiQz5JlXV+IfKh7mpfJac+lZ6V87QXVClBkTc7YWsWTPSDyitfzUTlJlj8TbvE6jluDOdwZ+jX57GLO3ADeuyZrDYi86vV81FD2UVGsmT+5Zl0BnkhoseOEaogL46pqO4v/IqUEyalIR4h85BgjHv6+aUWRMbb7EstX6O0cpT1Gco0ry8fWygLDMjmDnQeBt3Qe7uVfkeugDwVLcsVzGsuwLXbV+I63XNAkG5r/hvgRqgqWs6pJPKrsbvz/Q6yyun0w/h6lP+BnzrCpfPMT2L8FGAA7k1GZ/vnaqAAAAABJRU5ErkJggg=="
  286. },
  287. // 是否隐藏库存显示
  288. hideStock: {
  289. Type: Boolean,
  290. default: false
  291. },
  292. // 颜色主题
  293. theme: {
  294. Type: String,
  295. default: "default"
  296. },
  297. // 请求中的提示
  298. actionTips: {
  299. Type: String,
  300. default: "请求中..."
  301. },
  302. // 默认选中的SKU
  303. defaultSelect: {
  304. Type: Object
  305. },
  306. // 是否使用缓存
  307. useCache: {
  308. Type: Boolean,
  309. default: true
  310. },
  311. /**
  312. * 默认商品,设置该值可快速展示商品
  313. * 逻辑: 先展示 defaultGoods 信息,再取数据库,再更新页面(通常为更新库存)
  314. */
  315. defaultGoods: {
  316. Type: Object
  317. },
  318. /**
  319. * 金额是否需要除以100
  320. * 1:金额会除以100
  321. * 0:金额不会除以100
  322. */
  323. amountType: {
  324. Type: Number,
  325. default: 1
  326. },
  327. // 每次选择完SKU后,购买数量归1,如果有最小购买数量,则设置为最小购买数量
  328. selectedInit: {
  329. Type: Boolean,
  330. default: false
  331. },
  332. },
  333. data() {
  334. return {
  335. complete: false, // 组件是否加载完成
  336. goodsInfo: {}, // 商品信息
  337. isShow: false, // true 显示 false 隐藏
  338. initKey: true, // 是否已初始化
  339. shopItemInfo: {}, // 存放要和选中的值进行匹配的数据
  340. selectArr: [], // 存放被选中的值
  341. subIndex: [], // 是否选中 因为不确定是多规格还是单规格,所以这里定义数组来判断
  342. selectShop: {}, // 存放最后选中的商品
  343. selectNum: this.minBuyNum || 1, // 选中数量
  344. outFoStock: false, // 是否全部sku都缺货
  345. openTime: 0,
  346. themeColor: {
  347. // 默认主题
  348. default: {
  349. priceColor: "rgb(254, 86, 10)",
  350. buyNowColor: "#ffffff",
  351. buyNowBackgroundColor: "rgb(254, 86, 10)",
  352. addCartColor: "#ffffff",
  353. addCartBackgroundColor: "rgb(255, 148, 2)",
  354. btnStyle: {
  355. color: "#333333",
  356. borderColor: "#f4f4f4",
  357. backgroundColor: "#ffffff"
  358. },
  359. activedStyle: {
  360. color: "rgb(254, 86, 10)",
  361. borderColor: "rgb(254, 86, 10)",
  362. backgroundColor: "rgba(254,86,10,0.1)"
  363. },
  364. disableStyle: {
  365. color: "#c3c3c3",
  366. borderColor: "#f6f6f6",
  367. backgroundColor: "#f6f6f6"
  368. }
  369. },
  370. // 红黑主题
  371. "red-black": {
  372. priceColor: "rgb(255, 68, 68)",
  373. buyNowColor: "#ffffff",
  374. buyNowBackgroundColor: "rgb(255, 68, 68)",
  375. addCartColor: "#ffffff",
  376. addCartBackgroundColor: "rgb(85, 85, 85)",
  377. activedStyle: {
  378. color: "rgb(255, 68, 68)",
  379. borderColor: "rgb(255, 68, 68)",
  380. backgroundColor: "rgba(255,68,68,0.1)"
  381. }
  382. },
  383. // 黑白主题
  384. "black-white": {
  385. priceColor: "rgb(47, 47, 52)",
  386. buyNowColor: "#ffffff",
  387. buyNowBackgroundColor: "rgb(47, 47, 52)",
  388. addCartColor: "rgb(47, 47, 52)",
  389. addCartBackgroundColor: "rgb(235, 236, 242)",
  390. // btnStyle:{
  391. // color:"rgb(47, 47, 52)",
  392. // borderColor:"rgba(235,236,242,0.5)",
  393. // backgroundColor:"rgba(235,236,242,0.5)",
  394. // },
  395. activedStyle: {
  396. color: "rgb(47, 47, 52)",
  397. borderColor: "rgba(47,47,52,0.12)",
  398. backgroundColor: "rgba(47,47,52,0.12)"
  399. }
  400. },
  401. // 咖啡色主题
  402. coffee: {
  403. priceColor: "rgb(195, 167, 105)",
  404. buyNowColor: "#ffffff",
  405. buyNowBackgroundColor: "rgb(195, 167, 105)",
  406. addCartColor: "rgb(195, 167, 105)",
  407. addCartBackgroundColor: "rgb(243, 238, 225)",
  408. activedStyle: {
  409. color: "rgb(195, 167, 105)",
  410. borderColor: "rgb(195, 167, 105)",
  411. backgroundColor: "rgba(195, 167, 105,0.1)"
  412. }
  413. },
  414. // 浅绿色主题
  415. green: {
  416. priceColor: "rgb(99, 190, 114)",
  417. buyNowColor: "#ffffff",
  418. buyNowBackgroundColor: "rgb(99, 190, 114)",
  419. addCartColor: "rgb(99, 190, 114)",
  420. addCartBackgroundColor: "rgb(225, 244, 227)",
  421. activedStyle: {
  422. color: "rgb(99, 190, 114)",
  423. borderColor: "rgb(99, 190, 114)",
  424. backgroundColor: "rgba(99, 190, 114,0.1)"
  425. }
  426. }
  427. }
  428. };
  429. },
  430. created() {
  431. let that = this;
  432. vk = that.vk;
  433. if (that.getValue()) {
  434. that.open();
  435. }
  436. },
  437. mounted() {},
  438. methods: {
  439. // 初始化
  440. init(notAutoClick) {
  441. let that = this;
  442. // 清空之前的数据
  443. that.selectArr = [];
  444. that.subIndex = [];
  445. that.selectShop = {};
  446. that.selectNum = that.minBuyNum || 1;
  447. that.outFoStock = false;
  448. that.shopItemInfo = {};
  449. let specListName = that.specListName;
  450. that.goodsInfo[specListName].map(item => {
  451. that.selectArr.push("");
  452. that.subIndex.push(-1);
  453. });
  454. that.checkItem(); // 计算sku里面规格形成路径
  455. that.checkInpath(-1); // 传-1是为了不跳过循环
  456. if (!notAutoClick) that.autoClickSku(); // 自动选择sku策略
  457. },
  458. getValue() {
  459. // #ifndef VUE3
  460. return this.value;
  461. // #endif
  462. // #ifdef VUE3
  463. return this.modelValue;
  464. // #endif
  465. },
  466. // 使用vk路由模式框架获取商品信息
  467. findGoodsInfo(obj = {}) {
  468. let that = this;
  469. let { useCache } = obj;
  470. if (typeof vk == "undefined") {
  471. that.toast("custom-action必须是function", "none");
  472. return false;
  473. }
  474. let { actionTips } = that;
  475. let actionTitle = "";
  476. let actionAoading = false;
  477. if (actionTips !== "custom") {
  478. actionTitle = useCache ? "" : "请求中...";
  479. } else {
  480. actionAoading = useCache ? false : true;
  481. }
  482. vk.callFunction({
  483. url: that.action,
  484. title: actionTitle,
  485. loading: actionAoading,
  486. data: {
  487. goods_id: that.goodsId
  488. },
  489. success(data) {
  490. that.updateGoodsInfo(data.goodsInfo);
  491. // 更新缓存
  492. goodsCache[that.goodsId] = data.goodsInfo;
  493. that.$emit("update-goods", data.goodsInfo);
  494. },
  495. fail() {
  496. that.updateValue(false);
  497. }
  498. });
  499. },
  500. updateValue(value) {
  501. let that = this;
  502. if (value) {
  503. that.$emit("open", true);
  504. that.$emit("input", true);
  505. that.$emit("update:modelValue", true);
  506. } else {
  507. that.$emit("input", false);
  508. that.$emit("close", "close");
  509. that.$emit("update:modelValue", false);
  510. }
  511. },
  512. // 更新商品信息(库存、名称、图片)
  513. updateGoodsInfo(goodsInfo) {
  514. let that = this;
  515. // goodsInfo.sku_list.map((item, index) => {
  516. // item.sku_name_arr = ["20ml/瓶"];
  517. // });
  518. let { skuListName } = that;
  519. if (
  520. JSON.stringify(that.goodsInfo) === "{}" ||
  521. that.goodsInfo[that.goodsIdName] !== goodsInfo[that.goodsIdName]
  522. ) {
  523. that.goodsInfo = goodsInfo;
  524. that.initKey = true;
  525. } else {
  526. that.goodsInfo[skuListName] = goodsInfo[skuListName];
  527. }
  528. if (that.initKey) {
  529. that.initKey = false;
  530. that.init(that.isManyCom);
  531. }
  532. // 更新选中sku的库存信息
  533. let select_sku_info = that.getListItem(
  534. that.goodsInfo[skuListName],
  535. that.skuIdName,
  536. that.selectShop[that.skuIdName]
  537. );
  538. Object.assign(that.selectShop, select_sku_info);
  539. that.defaultSelectSku();
  540. that.complete = true;
  541. },
  542. async open() {
  543. let that = this;
  544. that.openTime = new Date().getTime();
  545. let findGoodsInfoRun = true;
  546. let skuListName = that.skuListName;
  547. // 先获取缓存中的商品信息
  548. let useCache = false;
  549. let goodsInfo = goodsCache[that.goodsId];
  550. if (goodsInfo && that.useCache) {
  551. useCache = true;
  552. that.updateGoodsInfo(goodsInfo);
  553. } else {
  554. that.complete = false;
  555. }
  556. if (that.customAction && typeof that.customAction === "function") {
  557. try {
  558. goodsInfo = await that
  559. .customAction({
  560. useCache,
  561. goodsId: that.goodsId,
  562. goodsInfo,
  563. close: function() {
  564. setTimeout(function() {
  565. that.close();
  566. }, 500);
  567. }
  568. })
  569. .catch(err => {
  570. setTimeout(function() {
  571. that.close();
  572. }, 500);
  573. });
  574. } catch (err) {
  575. let { message = "" } = err;
  576. if (message.indexOf(".catch is not a function") > -1) {
  577. that.toast("custom-action必须返回一个Promise", "none");
  578. setTimeout(function() {
  579. that.close();
  580. }, 500);
  581. return false;
  582. }
  583. }
  584. // 更新缓存
  585. goodsCache[that.goodsId] = goodsInfo;
  586. if (goodsInfo && typeof goodsInfo == "object" && JSON.stringify(goodsInfo) != "{}") {
  587. findGoodsInfoRun = false;
  588. that.updateGoodsInfo(goodsInfo);
  589. that.updateValue(true);
  590. } else {
  591. that.toast("未获取到商品信息", "none");
  592. that.$emit("input", false);
  593. return false;
  594. }
  595. } else if (typeof that.localdata !== "undefined" && that.localdata !== null) {
  596. goodsInfo = that.localdata;
  597. if (goodsInfo && typeof goodsInfo == "object" && JSON.stringify(goodsInfo) != "{}") {
  598. findGoodsInfoRun = false;
  599. that.updateGoodsInfo(goodsInfo);
  600. that.updateValue(true);
  601. } else {
  602. that.toast("未获取到商品信息", "none");
  603. that.$emit("input", false);
  604. return false;
  605. }
  606. } else {
  607. if (findGoodsInfoRun) that.findGoodsInfo({ useCache });
  608. }
  609. },
  610. // 监听 - 弹出层收起
  611. close(s) {
  612. let that = this;
  613. if (new Date().getTime() - that.openTime < 400) {
  614. return false;
  615. }
  616. if (s == "mask") {
  617. if (that.maskCloseAble !== false) {
  618. that.$emit("input", false);
  619. that.$emit("close", "mask");
  620. that.$emit("update:modelValue", false);
  621. }
  622. } else {
  623. that.$emit("input", false);
  624. that.$emit("close", "close");
  625. that.$emit("update:modelValue", false);
  626. }
  627. },
  628. moveHandle() {
  629. //禁止父元素滑动
  630. },
  631. // sku按钮的点击事件
  632. skuClick(value, index1, index2) {
  633. let that = this;
  634. if (value.ishow) {
  635. if (that.selectArr[index1] != value.name) {
  636. that.$set(that.selectArr, index1, value.name);
  637. that.$set(that.subIndex, index1, index2);
  638. } else {
  639. that.$set(that.selectArr, index1, "");
  640. that.$set(that.subIndex, index1, -1);
  641. }
  642. that.checkInpath(index1);
  643. // 如果全部选完
  644. that.checkSelectShop();
  645. }
  646. },
  647. // 检测是否已经选完sku
  648. checkSelectShop() {
  649. let that = this;
  650. // 如果全部选完
  651. if (that.selectArr.every(item => item != "")) {
  652. that.selectShop = that.shopItemInfo[that.getArrayToSting(that.selectArr)];
  653. let stock = that.selectShop[that.stockName];
  654. if (typeof stock !== "undefined" && that.selectNum > stock) {
  655. that.selectNum = stock;
  656. }
  657. if (that.selectNum > that.maxBuyNum) {
  658. that.selectNum = that.maxBuyNum;
  659. }
  660. if (that.selectNum < that.minBuyNum) {
  661. that.selectNum = that.minBuyNum;
  662. }
  663. if (that.selectedInit) {
  664. that.selectNum = that.minBuyNum || 1;
  665. }
  666. } else {
  667. that.selectShop = {};
  668. }
  669. },
  670. // 检查路径
  671. checkInpath(clickIndex) {
  672. let that = this;
  673. let specListName = that.specListName;
  674. //console.time('筛选可选路径需要的时间是');
  675. //循环所有属性判断哪些属性可选
  676. //当前选中的兄弟节点和已选中属性不需要循环
  677. let specList = that.goodsInfo[specListName];
  678. for (let i = 0, len = specList.length; i < len; i++) {
  679. if (i == clickIndex) {
  680. continue;
  681. }
  682. let len2 = specList[i].list.length;
  683. for (let j = 0; j < len2; j++) {
  684. if (that.subIndex[i] != -1 && j == that.subIndex[i]) {
  685. continue;
  686. }
  687. let choosed_copy = [...that.selectArr];
  688. that.$set(choosed_copy, i, specList[i].list[j].name);
  689. let choosed_copy2 = choosed_copy.filter(
  690. item => item !== "" && typeof item !== "undefined"
  691. );
  692. if (that.shopItemInfo.hasOwnProperty(that.getArrayToSting(choosed_copy2))) {
  693. specList[i].list[j].ishow = true;
  694. } else {
  695. specList[i].list[j].ishow = false;
  696. }
  697. }
  698. }
  699. that.$set(that.goodsInfo, specListName, specList);
  700. // console.timeEnd('筛选可选路径需要的时间是');
  701. },
  702. // 计算sku里面规格形成路径
  703. checkItem() {
  704. let that = this;
  705. // console.time('计算有多小种可选路径需要的时间是');
  706. let { stockName } = that;
  707. let skuListName = that.skuListName;
  708. // 去除库存小于等于0的商品sku
  709. let originalSkuList = that.goodsInfo[skuListName];
  710. let skuList = [];
  711. let stockNum = 0;
  712. originalSkuList.map((skuItem, index) => {
  713. if (skuItem[stockName] > 0) {
  714. skuList.push(skuItem);
  715. stockNum += skuItem[stockName];
  716. }
  717. });
  718. if (stockNum <= 0) {
  719. that.outFoStock = true;
  720. }
  721. // 计算有多小种可选路径
  722. let result = skuList.reduce(
  723. (arrs, items) => {
  724. return arrs.concat(
  725. items[that.skuArrName].reduce(
  726. (arr, item) => {
  727. return arr.concat(
  728. arr.map(item2 => {
  729. // 利用对象属性的唯一性实现二维数组去重
  730. //console.log(1,that.shopItemInfo,that.getArrayToSting([...item2, item]),item2,item,items);
  731. if (!that.shopItemInfo.hasOwnProperty(that.getArrayToSting([...item2, item]))) {
  732. that.shopItemInfo[that.getArrayToSting([...item2, item])] = items;
  733. }
  734. return [...item2, item];
  735. })
  736. );
  737. },
  738. [
  739. []
  740. ]
  741. )
  742. );
  743. },
  744. [
  745. []
  746. ]
  747. );
  748. // console.timeEnd('计算有多小种可选路径需要的时间是');
  749. },
  750. getArrayToSting(arr) {
  751. let str = "";
  752. arr.map((item, index) => {
  753. item = item.replace(/\./g, "。");
  754. if (index == 0) {
  755. str += item;
  756. } else {
  757. str += "," + item;
  758. }
  759. });
  760. return str;
  761. },
  762. // 检测sku选项是否已全部选完,且有库存
  763. checkSelectComplete(obj = {}) {
  764. let that = this;
  765. let clickTime = new Date().getTime();
  766. if (that.clickTime && clickTime - that.clickTime < 400) {
  767. return false;
  768. }
  769. that.clickTime = clickTime;
  770. let { selectShop, selectNum, stockText, stockName } = that;
  771. if (!selectShop || !selectShop[that.skuIdName]) {
  772. that.toast("请先选择对应规格", "none");
  773. return false;
  774. }
  775. if (selectNum <= 0) {
  776. that.toast("购买数量必须>0", "none");
  777. return false;
  778. }
  779. // 判断库存
  780. if (selectNum > selectShop[stockName]) {
  781. that.toast(stockText + "不足", "none");
  782. return false;
  783. }
  784. if (typeof obj.success == "function") obj.success(selectShop);
  785. },
  786. // 加入购物车
  787. addCart() {
  788. let that = this;
  789. that.checkSelectComplete({
  790. success: function(selectShop) {
  791. selectShop.buy_num = that.selectNum;
  792. that.$emit("add-cart", selectShop);
  793. // setTimeout(function() {
  794. // that.init();
  795. // }, 300);
  796. }
  797. });
  798. },
  799. // 立即购买
  800. buyNow() {
  801. let that = this;
  802. that.checkSelectComplete({
  803. success: function(selectShop) {
  804. selectShop.buy_num = that.selectNum;
  805. that.$emit("buy-now", selectShop);
  806. }
  807. });
  808. },
  809. // 弹窗
  810. toast(title, icon) {
  811. uni.showToast({
  812. title: title,
  813. icon: icon
  814. });
  815. },
  816. // 获取对象数组中的某一个item,根据指定的键值
  817. getListItem(list, key, value) {
  818. let that = this;
  819. let item;
  820. for (let i in list) {
  821. if (typeof value == "object") {
  822. if (JSON.stringify(list[i][key]) === JSON.stringify(value)) {
  823. item = list[i];
  824. break;
  825. }
  826. } else {
  827. if (list[i][key] === value) {
  828. item = list[i];
  829. break;
  830. }
  831. }
  832. }
  833. return item;
  834. },
  835. getListIndex(list, key, value) {
  836. let that = this;
  837. let index = -1;
  838. for (let i = 0; i < list.length; i++) {
  839. if (list[i][key] === value) {
  840. index = i;
  841. break;
  842. }
  843. }
  844. return index;
  845. },
  846. // 自动选择sku前提是只有一组sku,默认自动选择最前面的有库存的sku
  847. autoClickSku() {
  848. let that = this;
  849. let skuList = that.goodsInfo[that.skuListName];
  850. let specListArr = that.goodsInfo[that.specListName];
  851. if (specListArr.length == 1) {
  852. let specList = specListArr[0].list;
  853. for (let i = 0; i < specList.length; i++) {
  854. let sku = that.getListItem(skuList, that.skuArrName, [specList[i].name]);
  855. if (sku) {
  856. that.skuClick(specList[i], 0, i);
  857. break;
  858. }
  859. }
  860. }
  861. },
  862. // 主题颜色
  863. themeColorFn(name) {
  864. let that = this;
  865. let { theme, themeColor } = that;
  866. let color = that[name] ? that[name] : themeColor[theme][name];
  867. return color;
  868. },
  869. defaultSelectSku() {
  870. let that = this;
  871. let { defaultSelect } = that;
  872. if (defaultSelect && defaultSelect.sku && defaultSelect.sku.length > 0) {
  873. that.selectSku(defaultSelect);
  874. }
  875. },
  876. /**
  877. * 主动方法 - 设置sku
  878. that.$refs.skuPopup.selectSku({
  879. sku:["红色","256G","公开版"],
  880. num:5
  881. });
  882. */
  883. selectSku(obj = {}) {
  884. let that = this;
  885. let { sku: skuArr, num: selectNum } = obj;
  886. let specListArr = that.goodsInfo[that.specListName];
  887. if (skuArr && specListArr.length === skuArr.length) {
  888. // 先清空
  889. let skuClickArr = [];
  890. let clickKey = true;
  891. for (let index = 0; index < skuArr.length; index++) {
  892. let skuName = skuArr[index];
  893. let specList = specListArr[index].list;
  894. let index1 = index;
  895. let index2 = that.getListIndex(specList, "name", skuName);
  896. if (index2 == -1) {
  897. clickKey = false;
  898. break;
  899. }
  900. skuClickArr.push({
  901. spec: specList[index2],
  902. index1: index1,
  903. index2: index2
  904. });
  905. }
  906. if (clickKey) {
  907. that.init(true);
  908. skuClickArr.map(item => {
  909. that.skuClick(item.spec, item.index1, item.index2);
  910. });
  911. }
  912. }
  913. if (selectNum > 0) that.selectNum = selectNum;
  914. },
  915. priceFilter(n = 0) {
  916. let that = this;
  917. if (typeof n == "string") {
  918. n = parseFloat(n);
  919. }
  920. if (that.amountType === 0) {
  921. return n.toFixed(2);
  922. } else {
  923. return (n / 100).toFixed(2);
  924. }
  925. },
  926. pushGoodsCache(goodsInfo) {
  927. let that = this;
  928. let { goodsIdName } = that;
  929. goodsCache[goodsInfo[goodsIdName]] = goodsInfo;
  930. },
  931. // 用于阻止冒泡
  932. stop() {},
  933. // 图片预览
  934. previewImage() {
  935. let that = this;
  936. let { selectShop, goodsInfo, goodsThumbName } = that;
  937. let src = selectShop.image ? selectShop.image : goodsInfo[goodsThumbName];
  938. if (src) {
  939. uni.previewImage({
  940. urls: [src]
  941. });
  942. }
  943. }
  944. },
  945. // 计算属性
  946. computed: {
  947. // 最大购买数量
  948. maxBuyNumCom() {
  949. let that = this;
  950. let max = that.maxBuyNum || 100000;
  951. let stockName = that.stockName;
  952. if (that.selectShop && typeof that.selectShop[stockName] !== "undefined") {
  953. // 最大购买量不能超过当前商品的库存
  954. if (max > that.selectShop[stockName]) {
  955. max = that.selectShop[stockName];
  956. }
  957. }
  958. return max;
  959. },
  960. // 是否是多规格
  961. isManyCom() {
  962. let that = this;
  963. let { goodsInfo, defaultSingleSkuName, specListName } = that;
  964. let isMany = true;
  965. if (
  966. goodsInfo[specListName] &&
  967. goodsInfo[specListName].length === 1 &&
  968. goodsInfo[specListName][0].list.length === 1 &&
  969. goodsInfo[specListName][0].name === defaultSingleSkuName
  970. ) {
  971. isMany = false;
  972. }
  973. return isMany;
  974. },
  975. // 默认价格区间计算
  976. priceCom() {
  977. let str = "";
  978. let that = this;
  979. let { selectShop = {}, goodsInfo = {}, skuListName, skuIdName } = that;
  980. if (selectShop[skuIdName]) {
  981. str = that.priceFilter(selectShop.price);
  982. } else {
  983. let skuList = goodsInfo[skuListName];
  984. if (skuList && skuList.length > 0) {
  985. let valueArr = [];
  986. skuList.map((skuItem, index) => {
  987. valueArr.push(skuItem.price);
  988. });
  989. let min = that.priceFilter(Math.min(...valueArr));
  990. let max = that.priceFilter(Math.max(...valueArr));
  991. if (min === max) {
  992. str = min + "";
  993. } else {
  994. str = `${min} - ${max}`;
  995. }
  996. }
  997. }
  998. return str;
  999. },
  1000. // 库存显示
  1001. stockCom() {
  1002. let str = "";
  1003. let that = this;
  1004. let { selectShop = {}, goodsInfo = {}, skuListName, stockName } = that;
  1005. if (selectShop[stockName]) {
  1006. str = selectShop[stockName];
  1007. } else {
  1008. let skuList = goodsInfo[skuListName];
  1009. if (skuList && skuList.length > 0) {
  1010. let valueArr = [];
  1011. skuList.map((skuItem, index) => {
  1012. valueArr.push(skuItem[stockName]);
  1013. });
  1014. let min = Math.min(...valueArr);
  1015. let max = Math.max(...valueArr);
  1016. if (min === max) {
  1017. str = min;
  1018. } else {
  1019. str = `${min} - ${max}`;
  1020. }
  1021. }
  1022. }
  1023. return str;
  1024. },
  1025. },
  1026. watch: {
  1027. value(newVal, oldValue) {
  1028. let that = this;
  1029. if (newVal) {
  1030. that.open();
  1031. }
  1032. },
  1033. modelValue(newVal, oldValue) {
  1034. let that = this;
  1035. if (newVal) {
  1036. that.open();
  1037. }
  1038. },
  1039. defaultGoods: {
  1040. immediate: true,
  1041. handler: function(newVal, oldValue) {
  1042. let that = this;
  1043. let { goodsIdName } = that;
  1044. if (
  1045. typeof newVal === "object" &&
  1046. newVal &&
  1047. newVal[goodsIdName] &&
  1048. !goodsCache[newVal[goodsIdName]]
  1049. ) {
  1050. that.pushGoodsCache(newVal);
  1051. }
  1052. }
  1053. }
  1054. }
  1055. };
  1056. </script>
  1057. <style lang="scss" scoped>
  1058. /* sku弹出层 */
  1059. .goods-sku-popup {
  1060. position: fixed;
  1061. left: var(--window-left);
  1062. right: var(--window-right);
  1063. bottom: var(--window-bottom);
  1064. top: var(--window-top);
  1065. z-index: 21;
  1066. overflow: hidden;
  1067. &.show {
  1068. display: block;
  1069. .mask {
  1070. animation: showPopup 0.2s linear both;
  1071. }
  1072. .layer {
  1073. animation: showLayer 0.2s linear both;
  1074. bottom: var(--window-bottom);
  1075. }
  1076. }
  1077. &.hide {
  1078. .mask {
  1079. animation: hidePopup 0.2s linear both;
  1080. }
  1081. .layer {
  1082. animation: hideLayer 0.2s linear both;
  1083. }
  1084. }
  1085. &.none {
  1086. display: none;
  1087. }
  1088. .mask {
  1089. position: fixed;
  1090. left: var(--window-left);
  1091. right: var(--window-right);
  1092. top: 0;
  1093. height: 100%;
  1094. z-index: 1;
  1095. background-color: rgba(0, 0, 0, 0.65);
  1096. }
  1097. .layer {
  1098. display: flex;
  1099. flex-direction: column;
  1100. position: fixed;
  1101. left: var(--window-left);
  1102. right: var(--window-right);
  1103. bottom: var(--window-bottom);
  1104. z-index: 99;
  1105. border-radius: 10rpx 10rpx 0 0;
  1106. background-color: #fff;
  1107. // 设置ios刘海屏底部横线安全区域
  1108. padding-bottom: constant(safe-area-inset-bottom);
  1109. padding-bottom: env(safe-area-inset-bottom);
  1110. .specification-wrapper {
  1111. width: 100%;
  1112. padding: 30rpx 25rpx;
  1113. box-sizing: border-box;
  1114. .specification-wrapper-content {
  1115. width: 100%;
  1116. max-height: 900rpx;
  1117. min-height: 300rpx;
  1118. &::-webkit-scrollbar {
  1119. /*隐藏滚轮*/
  1120. display: none;
  1121. }
  1122. .specification-header {
  1123. width: 100%;
  1124. display: flex;
  1125. flex-direction: row;
  1126. position: relative;
  1127. margin-bottom: 40rpx;
  1128. .specification-left {
  1129. width: 180rpx;
  1130. height: 180rpx;
  1131. flex: 0 0 180rpx;
  1132. .product-img {
  1133. width: 180rpx;
  1134. height: 180rpx;
  1135. }
  1136. }
  1137. .specification-right {
  1138. flex: 1;
  1139. padding: 0 35rpx 10rpx 28rpx;
  1140. box-sizing: border-box;
  1141. display: flex;
  1142. flex-direction: column;
  1143. justify-content: flex-end;
  1144. font-weight: 500;
  1145. .price-content {
  1146. color: #fe560a;
  1147. margin-bottom: 10rpx;
  1148. .sign {
  1149. font-size: 28rpx;
  1150. margin-right: 4rpx;
  1151. }
  1152. .price {
  1153. margin-left: 4rpx;
  1154. font-size: 48rpx;
  1155. }
  1156. .price2 {
  1157. margin-left: 4rpx;
  1158. font-size: 36rpx;
  1159. }
  1160. }
  1161. .inventory {
  1162. font-size: 24rpx;
  1163. color: #525252;
  1164. margin-bottom: 14rpx;
  1165. }
  1166. .choose {
  1167. font-size: 24rpx;
  1168. color: #525252;
  1169. min-height: 32rpx;
  1170. }
  1171. }
  1172. }
  1173. .specification-content {
  1174. font-weight: 500;
  1175. .specification-item {
  1176. margin-bottom: 40rpx;
  1177. &:last-child {
  1178. margin-bottom: 0;
  1179. }
  1180. .item-title {
  1181. margin-bottom: 20rpx;
  1182. font-size: 28rpx;
  1183. color: #999999;
  1184. }
  1185. .item-wrapper {
  1186. display: flex;
  1187. flex-direction: row;
  1188. flex-flow: wrap;
  1189. margin-bottom: -20rpx;
  1190. .item-content {
  1191. display: inline-block;
  1192. padding: 10rpx 35rpx;
  1193. font-size: 24rpx;
  1194. border-radius: 10rpx;
  1195. background-color: #ffffff;
  1196. color: #333333;
  1197. margin-right: 20rpx;
  1198. margin-bottom: 20rpx;
  1199. border: 2rpx solid #f4f4f4;
  1200. box-sizing: border-box;
  1201. &.actived {
  1202. border-color: #fe560a;
  1203. color: #fe560a;
  1204. }
  1205. &.noactived {
  1206. // background-color: #f6f6f6;
  1207. // border-color: #f6f6f6;
  1208. // color: #c3c3c3;
  1209. color: #c8c9cc;
  1210. background: #f2f3f5;
  1211. border-color: #f2f3f5;
  1212. }
  1213. }
  1214. }
  1215. }
  1216. .number-box-view {
  1217. display: flex;
  1218. padding-top: 20rpx;
  1219. }
  1220. }
  1221. }
  1222. .close {
  1223. position: absolute;
  1224. top: 30rpx;
  1225. right: 25rpx;
  1226. width: 50rpx;
  1227. height: 50rpx;
  1228. text-align: center;
  1229. line-height: 50rpx;
  1230. .close-item {
  1231. width: 40rpx;
  1232. height: 40rpx;
  1233. }
  1234. }
  1235. }
  1236. .btn-wrapper {
  1237. display: flex;
  1238. width: 100%;
  1239. height: 120rpx;
  1240. flex: 0 0 120rpx;
  1241. align-items: center;
  1242. justify-content: space-between;
  1243. padding: 0 26rpx;
  1244. box-sizing: border-box;
  1245. .layer-btn {
  1246. width: 335rpx;
  1247. height: 76rpx;
  1248. border-radius: 38rpx;
  1249. color: #fff;
  1250. line-height: 76rpx;
  1251. text-align: center;
  1252. font-weight: 500;
  1253. font-size: 28rpx;
  1254. &.add-cart {
  1255. background: #ffbe46;
  1256. }
  1257. &.buy {
  1258. background: #fe560a;
  1259. }
  1260. }
  1261. .sure {
  1262. margin: 0 auto;
  1263. width: 95%;
  1264. max-width: 1200rpx;
  1265. height: 80rpx;
  1266. border-radius: 38rpx;
  1267. color: #fff;
  1268. line-height: 80rpx;
  1269. text-align: center;
  1270. font-weight: 500;
  1271. font-size: 28rpx;
  1272. background: #fe560a;
  1273. }
  1274. .sure.add-cart {
  1275. background: #ff9402;
  1276. }
  1277. }
  1278. }
  1279. @keyframes showPopup {
  1280. 0% {
  1281. opacity: 0;
  1282. }
  1283. 100% {
  1284. opacity: 1;
  1285. }
  1286. }
  1287. @keyframes hidePopup {
  1288. 0% {
  1289. opacity: 1;
  1290. }
  1291. 100% {
  1292. opacity: 0;
  1293. }
  1294. }
  1295. @keyframes showLayer {
  1296. 0% {
  1297. transform: translateY(120%);
  1298. }
  1299. 100% {
  1300. transform: translateY(0%);
  1301. }
  1302. }
  1303. @keyframes hideLayer {
  1304. 0% {
  1305. transform: translateY(0);
  1306. }
  1307. 100% {
  1308. transform: translateY(120%);
  1309. }
  1310. }
  1311. }
  1312. </style>