index.vue 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360
  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();
  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: 0;
  1062. top: 0;
  1063. right: 0;
  1064. bottom: 0;
  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. top: 0;
  1091. width: 100%;
  1092. height: 100%;
  1093. z-index: 1;
  1094. background-color: rgba(0, 0, 0, 0.65);
  1095. }
  1096. .layer {
  1097. display: flex;
  1098. width: 100%;
  1099. // height: 1014rpx;
  1100. flex-direction: column;
  1101. // min-height: 40vh;
  1102. // max-height: 1014rpx;
  1103. position: fixed;
  1104. z-index: 99;
  1105. bottom: 0;
  1106. border-radius: 10rpx 10rpx 0 0;
  1107. background-color: #fff;
  1108. .specification-wrapper {
  1109. width: 100%;
  1110. padding: 30rpx 25rpx;
  1111. box-sizing: border-box;
  1112. .specification-wrapper-content {
  1113. width: 100%;
  1114. max-height: 900rpx;
  1115. min-height: 300rpx;
  1116. &::-webkit-scrollbar {
  1117. /*隐藏滚轮*/
  1118. display: none;
  1119. }
  1120. .specification-header {
  1121. width: 100%;
  1122. display: flex;
  1123. flex-direction: row;
  1124. position: relative;
  1125. margin-bottom: 40rpx;
  1126. .specification-left {
  1127. width: 180rpx;
  1128. height: 180rpx;
  1129. flex: 0 0 180rpx;
  1130. .product-img {
  1131. width: 180rpx;
  1132. height: 180rpx;
  1133. }
  1134. }
  1135. .specification-right {
  1136. flex: 1;
  1137. padding: 0 35rpx 10rpx 28rpx;
  1138. box-sizing: border-box;
  1139. display: flex;
  1140. flex-direction: column;
  1141. justify-content: flex-end;
  1142. font-weight: 500;
  1143. .price-content {
  1144. color: #fe560a;
  1145. margin-bottom: 10rpx;
  1146. .sign {
  1147. font-size: 28rpx;
  1148. margin-right: 4rpx;
  1149. }
  1150. .price {
  1151. margin-left: 4rpx;
  1152. font-size: 48rpx;
  1153. }
  1154. .price2 {
  1155. margin-left: 4rpx;
  1156. font-size: 36rpx;
  1157. }
  1158. }
  1159. .inventory {
  1160. font-size: 24rpx;
  1161. color: #525252;
  1162. margin-bottom: 14rpx;
  1163. }
  1164. .choose {
  1165. font-size: 24rpx;
  1166. color: #525252;
  1167. min-height: 32rpx;
  1168. }
  1169. }
  1170. }
  1171. .specification-content {
  1172. font-weight: 500;
  1173. .specification-item {
  1174. margin-bottom: 40rpx;
  1175. &:last-child {
  1176. margin-bottom: 0;
  1177. }
  1178. .item-title {
  1179. margin-bottom: 20rpx;
  1180. font-size: 28rpx;
  1181. color: #999999;
  1182. }
  1183. .item-wrapper {
  1184. display: flex;
  1185. flex-direction: row;
  1186. flex-flow: wrap;
  1187. margin-bottom: -20rpx;
  1188. .item-content {
  1189. display: inline-block;
  1190. padding: 10rpx 35rpx;
  1191. font-size: 24rpx;
  1192. border-radius: 10rpx;
  1193. background-color: #ffffff;
  1194. color: #333333;
  1195. margin-right: 20rpx;
  1196. margin-bottom: 20rpx;
  1197. border: 2rpx solid #f4f4f4;
  1198. box-sizing: border-box;
  1199. &.actived {
  1200. border-color: #fe560a;
  1201. color: #fe560a;
  1202. }
  1203. &.noactived {
  1204. // background-color: #f6f6f6;
  1205. // border-color: #f6f6f6;
  1206. // color: #c3c3c3;
  1207. color: #c8c9cc;
  1208. background: #f2f3f5;
  1209. border-color: #f2f3f5;
  1210. }
  1211. }
  1212. }
  1213. }
  1214. .number-box-view {
  1215. display: flex;
  1216. padding-top: 20rpx;
  1217. }
  1218. }
  1219. }
  1220. .close {
  1221. position: absolute;
  1222. top: 30rpx;
  1223. right: 25rpx;
  1224. width: 50rpx;
  1225. height: 50rpx;
  1226. text-align: center;
  1227. line-height: 50rpx;
  1228. .close-item {
  1229. width: 40rpx;
  1230. height: 40rpx;
  1231. }
  1232. }
  1233. }
  1234. .btn-wrapper {
  1235. display: flex;
  1236. width: 100%;
  1237. height: 120rpx;
  1238. flex: 0 0 120rpx;
  1239. align-items: center;
  1240. justify-content: space-between;
  1241. padding: 0 26rpx;
  1242. box-sizing: border-box;
  1243. .layer-btn {
  1244. width: 335rpx;
  1245. height: 76rpx;
  1246. border-radius: 38rpx;
  1247. color: #fff;
  1248. line-height: 76rpx;
  1249. text-align: center;
  1250. font-weight: 500;
  1251. font-size: 28rpx;
  1252. &.add-cart {
  1253. background: #ffbe46;
  1254. }
  1255. &.buy {
  1256. background: #fe560a;
  1257. }
  1258. }
  1259. .sure {
  1260. width: 698rpx;
  1261. height: 80rpx;
  1262. border-radius: 38rpx;
  1263. color: #fff;
  1264. line-height: 80rpx;
  1265. text-align: center;
  1266. font-weight: 500;
  1267. font-size: 28rpx;
  1268. background: #fe560a;
  1269. }
  1270. .sure.add-cart {
  1271. background: #ff9402;
  1272. }
  1273. }
  1274. }
  1275. @keyframes showPopup {
  1276. 0% {
  1277. opacity: 0;
  1278. }
  1279. 100% {
  1280. opacity: 1;
  1281. }
  1282. }
  1283. @keyframes hidePopup {
  1284. 0% {
  1285. opacity: 1;
  1286. }
  1287. 100% {
  1288. opacity: 0;
  1289. }
  1290. }
  1291. @keyframes showLayer {
  1292. 0% {
  1293. transform: translateY(120%);
  1294. }
  1295. 100% {
  1296. transform: translateY(0%);
  1297. }
  1298. }
  1299. @keyframes hideLayer {
  1300. 0% {
  1301. transform: translateY(0);
  1302. }
  1303. 100% {
  1304. transform: translateY(120%);
  1305. }
  1306. }
  1307. }
  1308. </style>