detail_groupbuy.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867
  1. import {
  2. aftersale,
  3. modifyClicks,
  4. addGoodsbrowse,
  5. goodsQrcode
  6. } from "@/api/goods/goods"
  7. import {
  8. goodsCategoryInfo
  9. } from "@/api/goods/goodscategory"
  10. import {
  11. goodsSkuDetail,
  12. goodsSkuInfo,
  13. evaluateConfig
  14. } from "@/api/groupbuy"
  15. import {
  16. isCollect,
  17. addCollect,
  18. deleteCollect
  19. } from "@/api/goods/goods_collect"
  20. import {
  21. goodsEvaluateList,
  22. goodsEvaluateCount
  23. } from "@/api/goods/evaluate"
  24. import {
  25. mapGetters
  26. } from "vuex"
  27. import CountDown from "vue2-countdown"
  28. // import {
  29. // shopIsSubscribe,
  30. // addShopSubscribe,
  31. // deleteShopSubscribe
  32. // } from "@/api/shop"
  33. import {
  34. getArea
  35. } from "@/api/address"
  36. import {
  37. shopServiceOpen
  38. } from "@/api/website.js"
  39. export default {
  40. data: () => {
  41. return {
  42. id: 0,
  43. skuId: 0,
  44. loading: true,
  45. picZoomUrl: "",
  46. thumbPosition: 0,
  47. // 是否可以移动
  48. moveThumbLeft: false,
  49. moveThumbRight: false,
  50. // 商品详情
  51. goodsSkuDetail: {
  52. video_url: ""
  53. },
  54. groupbuyText: "距离结束仅剩",
  55. groupbuyTimeMachine: {
  56. currentTime: 0,
  57. startTime: 0,
  58. endTime: 0
  59. },
  60. qrcode: "",
  61. specDisabled: false,
  62. specBtnRepeat: false, //防止重复
  63. btnSwitch: false,
  64. // 店铺详情
  65. shopInfo: {},
  66. whetherCollection: 0,
  67. score: 0,
  68. //评价
  69. currentPage: 1,
  70. pageSize: 25,
  71. total: 0,
  72. evaluaType: 0,//评价类型
  73. evaluteCount:{},//评价数量
  74. goodsEvaluateList: [],
  75. evaluate_show: false, //是否显示评论
  76. service: null,
  77. number: 1,
  78. limitNumber: 0,
  79. tabName: "detail",
  80. playerOptions: {
  81. playbackRates: [0.5, 1.0, 1.5, 2.0, 3.0], // 可选的播放速度
  82. autoplay: false, // 如果为true,浏览器准备好时开始回放。
  83. muted: false, // 默认情况下将会消除任何音频。
  84. loop: false, // 是否视频一结束就重新开始。
  85. preload: "auto", // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频(如果浏览器支持)
  86. language: "zh-CN",
  87. aspectRatio: "16:9", // 将播放器置于流畅模式,并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字(例如"16:9"或"4:3")
  88. fluid: true, // 当true时,Video.js player将拥有流体大小。换句话说,它将按比例缩放以适应其容器。
  89. sources: [{
  90. type: "video/mp4", // 类型
  91. src: "" // url地址
  92. }],
  93. poster: "", // 封面地址
  94. notSupportedMessage: "此视频暂无法播放,请稍后再试", // 允许覆盖Video.js无法播放媒体源时显示的默认信息。
  95. controlBar: {
  96. timeDivider: true, // 当前时间和持续时间的分隔符
  97. durationDisplay: true, // 显示持续时间
  98. remainingTimeDisplay: true, // 是否显示剩余时间功能
  99. fullscreenToggle: true // 是否显示全屏按钮
  100. }
  101. },
  102. switchMedia: "img",
  103. // 是否关注店铺
  104. hasFollow: false,
  105. // 客服配置
  106. kefuConfig: {
  107. system: '',
  108. open_pc: '',
  109. open_url: ''
  110. },
  111. // 省市区县
  112. provinceArr: {},
  113. cityArr: {},
  114. districtArr: {},
  115. // 省市区县 id
  116. currTabAddres: "province",
  117. hideRegion: false,
  118. selectedAddress: {},
  119. service_list: [], //商品服务
  120. serverType: 'disable',
  121. serverThird: '',
  122. categoryNameArr:[]
  123. }
  124. },
  125. components: {
  126. CountDown
  127. },
  128. created() {
  129. this.id = this.$route.params.id;
  130. if (this.addonIsExit && this.addonIsExit.groupbuy != 1) {
  131. this.$message({
  132. message: '团购插件未安装',
  133. type: 'warning',
  134. duration: 2000,
  135. onClose: () => {
  136. this.$route.push('/');
  137. }
  138. });
  139. } else {
  140. this.getGoodsSkuDetail()
  141. this.shopServiceOpen()
  142. this.getGoodsEvaluate()
  143. this.goodsEvaluCount()
  144. }
  145. },
  146. computed: {
  147. ...mapGetters(["token", "siteInfo", "defaultHeadImage", "defaultShopImage", "addonIsExit", 'locationRegion'])
  148. },
  149. watch: {
  150. $route(curr) {
  151. this.id = curr.query.id
  152. if (this.addonIsExit && this.addonIsExit.groupbuy != 1) {
  153. this.$message({
  154. message: '团购插件未安装',
  155. type: 'warning',
  156. duration: 2000,
  157. onClose: () => {
  158. this.$route.push('/');
  159. }
  160. });
  161. } else {
  162. this.getGoodsSkuDetail()
  163. this.shopServiceOpen()
  164. }
  165. },
  166. addonIsExit() {
  167. if (this.addonIsExit.groupbuy != 1) {
  168. this.$message({
  169. message: '团购插件未安装',
  170. type: 'warning',
  171. duration: 2000,
  172. onClose: () => {
  173. this.$route.push('/');
  174. }
  175. });
  176. }
  177. }
  178. },
  179. methods: {
  180. shopServiceOpen() {
  181. shopServiceOpen().then((res) => {
  182. if (res.code == 0) {
  183. this.kefuConfig = res.data;
  184. }
  185. })
  186. },
  187. tabChange(tab, event) {},
  188. bundlingChange(tab, event) {},
  189. getGoodsSkuDetail() {
  190. goodsSkuDetail({
  191. groupbuy_id: this.id
  192. })
  193. .then(res => {
  194. let data = res.data
  195. if (data.goods_sku_detail != null) {
  196. this.goodsSkuDetail = data.goods_sku_detail
  197. let categoryIdArr = data.goods_sku_detail.category_id.split(",")
  198. categoryIdArr = categoryIdArr.filter((item)=>{
  199. return item&&item.trim()
  200. });
  201. this.categorySearch(categoryIdArr[categoryIdArr.length-1]);
  202. // this.shopInfo = data.shop_info
  203. this.service_list = data.goods_sku_detail.goods_service
  204. this.skuId = this.goodsSkuDetail.sku_id
  205. this.number = this.goodsSkuDetail.buy_num
  206. this.limitNumber = this.goodsSkuDetail.buy_num
  207. //团购倒计时
  208. if (this.goodsSkuDetail.end_time - res.timestamp > 0) {
  209. this.groupbuyTimeMachine = {
  210. currentTime: res.timestamp,
  211. startTime: res.timestamp,
  212. endTime: this.goodsSkuDetail.end_time
  213. }
  214. } else {
  215. this.$message({
  216. message: '活动已结束',
  217. type: 'warning',
  218. duration: 2000,
  219. onClose: () => {
  220. this.$router.push("/sku/" + this.goodsSkuDetail.sku_id)
  221. }
  222. });
  223. }
  224. if (this.goodsSkuDetail.sku_images) this.goodsSkuDetail.sku_images = this.goodsSkuDetail.sku_images.split(",");
  225. else this.goodsSkuDetail.sku_images = [];
  226. // 多规格时合并主图
  227. if (this.goodsSkuDetail.goods_spec_format && this.goodsSkuDetail.goods_image) {
  228. this.goodsSkuDetail.goods_image = this.goodsSkuDetail.goods_image.split(",");
  229. this.goodsSkuDetail.sku_images = this.goodsSkuDetail.sku_images.concat(this.goodsSkuDetail.goods_image);
  230. }
  231. //媒体
  232. if (this.goodsSkuDetail.video_url) {
  233. this.switchMedia = "video"
  234. this.playerOptions.poster = this.$img(this.goodsSkuDetail.sku_images[0])
  235. this.playerOptions.sources[0].src = this.$img(this.goodsSkuDetail.video_url)
  236. }
  237. this.picZoomUrl = this.goodsSkuDetail.sku_images[0]
  238. this.goodsSkuDetail.unit = this.goodsSkuDetail.unit || "件"
  239. // 当前商品SKU规格
  240. if (this.goodsSkuDetail.sku_spec_format) this.goodsSkuDetail.sku_spec_format = JSON.parse(this.goodsSkuDetail.sku_spec_format)
  241. // 商品属性
  242. if (this.goodsSkuDetail.goods_attr_format) {
  243. let goods_attr_format = JSON.parse(this.goodsSkuDetail.goods_attr_format);
  244. this.goodsSkuDetail.goods_attr_format = this.$util.unique(goods_attr_format, "attr_id");
  245. for (var i = 0; i < this.goodsSkuDetail.goods_attr_format.length; i++) {
  246. for (var j = 0; j < goods_attr_format.length; j++) {
  247. if (this.goodsSkuDetail.goods_attr_format[i].attr_id == goods_attr_format[j].attr_id && this.goodsSkuDetail.goods_attr_format[
  248. i].attr_value_id != goods_attr_format[j].attr_value_id) {
  249. this.goodsSkuDetail.goods_attr_format[i].attr_value_name += "、" + goods_attr_format[j].attr_value_name;
  250. }
  251. }
  252. }
  253. }
  254. // 商品SKU格式
  255. if (this.goodsSkuDetail.goods_spec_format) this.goodsSkuDetail.goods_spec_format = JSON.parse(this.goodsSkuDetail
  256. .goods_spec_format)
  257. window.document.title = `${this.goodsSkuDetail.sku_name} - ${this.siteInfo.site_name}`
  258. this.loading = false
  259. } else {
  260. this.$router.push("/")
  261. }
  262. })
  263. .then(res => {
  264. if (this.token != "") {
  265. this.getWhetherCollection()
  266. // this.isFollow()
  267. }
  268. // this.getAftersale()
  269. this.modifyGoodsInfo()
  270. this.getGoodsQrcode()
  271. this.getEvaluateConfig()
  272. this.getAddress('province', null, true);
  273. if (!this.locationRegion) {
  274. this.$store.commit("app/SET_LOCATION_REGION", {
  275. "level_1": {
  276. "id": 110000,
  277. "pid": 0,
  278. "name": "北京市",
  279. "shortname": "北京",
  280. "longitude": "116.40529",
  281. "latitude": "39.904987",
  282. "level": 1,
  283. "sort": 1,
  284. "status": 1,
  285. "default_data": 1
  286. },
  287. "level_2": {
  288. "id": 110100,
  289. "pid": 110000,
  290. "name": "北京市",
  291. "shortname": "北京",
  292. "longitude": "116.40529",
  293. "latitude": "39.904987",
  294. "level": 2,
  295. "sort": 1,
  296. "status": 1,
  297. "default_data": 1
  298. },
  299. "level_3": {
  300. "id": 110101,
  301. "pid": 110100,
  302. "name": "东城区",
  303. "shortname": "东城",
  304. "longitude": "116.418755",
  305. "latitude": "39.917545",
  306. "level": 3,
  307. "sort": 3,
  308. "status": 1,
  309. "default_data": 1
  310. }
  311. });
  312. }
  313. this.selectedAddress = this.locationRegion;
  314. this.provinceId = this.selectedAddress.level_1.id
  315. this.getAddress('city', null, true, () => {
  316. this.cityId = this.selectedAddress.level_2.id
  317. if (this.cityId) this.getAddress('district', null, true)
  318. });
  319. })
  320. .catch(res => {
  321. this.loading = false
  322. this.$router.push("/")
  323. })
  324. },
  325. categorySearch(category_id) {
  326. goodsCategoryInfo({
  327. category_id: category_id
  328. }).then(res => {
  329. if (res.code == 0 && res.data) {
  330. this.categoryNameArr = [];
  331. try{
  332. let categoryArr = res.data.category_full_name.split("$_SPLIT_$");
  333. categoryArr.forEach((item,index)=>{
  334. let obj = {};
  335. obj.name = item;
  336. obj.category_id = res.data["category_id_"+(index+1)];
  337. this.categoryNameArr.push(obj);
  338. })
  339. }catch(e){
  340. this.categoryNameArr = [];
  341. }
  342. console.log("this.categoryNameArr",this.categoryNameArr);
  343. }
  344. }).catch(err => {
  345. })
  346. },
  347. getEvaluateConfig() {
  348. evaluateConfig()
  349. .then(res => {
  350. console.log(res,'getEvaluateConfig')
  351. if (res.code == 0) {
  352. var data = res.data;
  353. this.evaluateConfig = data;
  354. if (this.evaluateConfig.evaluate_show == 1) {
  355. //商品评论
  356. this.evaluate_show = true
  357. this.getGoodsEvaluate();
  358. }
  359. }
  360. })
  361. },
  362. service_link() {
  363. if (this.token) {
  364. this.$refs.servicerMessage.show();
  365. } else {
  366. this.$message({
  367. message: "您还未登录",
  368. type: "warning"
  369. })
  370. }
  371. },
  372. changeThumbImg(tag) {
  373. if (this.goodsSkuDetail.sku_images.length < 4) return
  374. let page = this.goodsSkuDetail.sku_images.length % 4 // 可见数量4个
  375. let position = 94
  376. if (page == 0) page = this.goodsSkuDetail.sku_images.length - 4 // 可见数量4个
  377. else if (page != 0 && page != 1 && page < 2) return
  378. if (tag == "prev") {
  379. if (this.thumbPosition != 0 && Math.round(this.thumbPosition, 2) != position) {
  380. this.thumbPosition += position
  381. // this.moveThumbLeft = true;
  382. } else {
  383. // this.moveThumbLeft = false;
  384. }
  385. } else if (tag == "next") {
  386. if (Math.round(this.thumbPosition, 2) != -Math.round(position * page, 2)) {
  387. this.thumbPosition -= position
  388. // this.moveThumbRight = true;
  389. } else {
  390. // this.moveThumbRight = false;
  391. }
  392. }
  393. },
  394. //获取用户是否关注
  395. getWhetherCollection() {
  396. isCollect({
  397. goods_id: this.goodsSkuDetail.goods_id
  398. }).then(res => {
  399. this.whetherCollection = res.data;
  400. })
  401. },
  402. editCollection() {
  403. //未关注添加关注
  404. if (this.whetherCollection == 0) {
  405. addCollect({
  406. sku_id: this.skuId,
  407. goods_id: this.goodsSkuDetail.goods_id
  408. }).then(res => {
  409. var data = res.data
  410. if (data > 0) {
  411. this.whetherCollection = 1
  412. this.goodsSkuDetail.collect_num++
  413. }
  414. })
  415. } else {
  416. //已关注取消关注
  417. deleteCollect({
  418. goods_id: this.goodsSkuDetail.goods_id
  419. }).then(res => {
  420. var data = res.data
  421. if (data > 0) {
  422. this.whetherCollection = 0
  423. this.goodsSkuDetail.collect_num--
  424. }
  425. })
  426. }
  427. },
  428. // 售后保障
  429. getAftersale() {
  430. aftersale({}).then(res => {
  431. if (res.code == 0 && res.data) {
  432. let data = res.data.content
  433. if (res.data.content) this.service = res.data.content
  434. }
  435. })
  436. },
  437. //更新商品信息
  438. modifyGoodsInfo() {
  439. //更新商品点击量
  440. modifyClicks({
  441. sku_id: this.skuId,
  442. })
  443. //添加足迹
  444. addGoodsbrowse({
  445. sku_id: this.skuId,
  446. goods_id: this.goodsSkuDetail.goods_id
  447. })
  448. },
  449. // 商品二维码
  450. getGoodsQrcode() {
  451. goodsQrcode({
  452. sku_id: this.skuId
  453. }).then(res => {
  454. let data = res.data
  455. if (data.path.h5.img) this.qrcode = this.$img(data.path.h5.img)
  456. })
  457. },
  458. //商品评价数量
  459. goodsEvaluCount(){
  460. goodsEvaluateCount({
  461. goods_id: this.id
  462. }).then(res =>{
  463. if(res.code == 0 && res.data){
  464. this.evaluteCount = res.data
  465. }
  466. })
  467. },
  468. // 商品评价列表
  469. getGoodsEvaluate() {
  470. goodsEvaluateList({
  471. page: this.currentPage,
  472. page_size: this.pageSize,
  473. goods_id: this.id,
  474. explain_type: this.evaluaType == 0 ? '' : this.evaluaType
  475. }).then(res => {
  476. let list = []
  477. let msg = res.message
  478. if (res.code == 0 && res.data) {
  479. list = res.data.list
  480. this.total = res.data.count
  481. }
  482. for (var i = 0; i < list.length; i++) {
  483. // 1好评2中评3差评
  484. if (list[i].explain_type == 1) {
  485. list[i].star = 5
  486. } else if (list[i].explain_type == 2) {
  487. list[i].star = 3
  488. } else if (list[i].explain_type == 3) {
  489. list[i].star = 1
  490. }
  491. if (list[i].images) {
  492. list[i].images = list[i].images.split(",")
  493. list[i].imagesFormat = []
  494. for (var k = 0; k < list[i].images.length; k++) {
  495. list[i].imagesFormat.push(this.$img(list[i].images[k]))
  496. }
  497. }
  498. if (list[i].again_images) {
  499. list[i].again_images = list[i].again_images.split(",")
  500. list[i].againImagesFormat = []
  501. for (var j = 0; j < list[i].again_images.length; j++) {
  502. list[i].againImagesFormat.push(this.$img(list[i].again_images[j]))
  503. }
  504. }
  505. if (list[i].is_anonymous == 1) list[i].member_name = list[i].member_name.replace(list[i].member_name.substring(1,
  506. list[i].member_name.length - 1), "***")
  507. }
  508. this.goodsEvaluateList = list
  509. })
  510. },
  511. // 图片加载失败
  512. imageErrorEvaluate(index) {
  513. this.goodsEvaluateList[index].member_headimg = this.defaultHeadImage
  514. },
  515. handlePageSizeChange(size) {
  516. this.pageSize = size
  517. this.getGoodsEvaluate()
  518. },
  519. handleCurrentPageChange(page) {
  520. this.currentPage = page
  521. this.getGoodsEvaluate()
  522. },
  523. changeSpec(skuId, spec_id) {
  524. if (this.specDisabled) return
  525. this.specBtnRepeat = false
  526. this.skuId = skuId
  527. // 清空选择
  528. for (var i = 0; i < this.goodsSkuDetail.goods_spec_format.length; i++) {
  529. var sku = this.goodsSkuDetail.goods_spec_format[i]
  530. for (var j = 0; j < sku.value.length; j++) {
  531. // 排除当前点击的规格值
  532. if (spec_id == this.goodsSkuDetail.goods_spec_format[i].value[j].spec_id) {
  533. this.goodsSkuDetail.goods_spec_format[i].value[j].selected = false
  534. }
  535. }
  536. }
  537. goodsSkuInfo({
  538. sku_id: this.skuId,
  539. id: this.goodsSkuDetail.groupbuy_id
  540. }).then(res => {
  541. console.log(res,'goodsSkuInfo')
  542. let data = res.data
  543. if (data != null) {
  544. data.sku_images = data.sku_images.split(",")
  545. this.picZoomUrl = data.sku_images[0]
  546. this.playerOptions.poster = this.$img(data.sku_images[0])
  547. // 当前商品SKU规格
  548. if (data.sku_spec_format) data.sku_spec_format = JSON.parse(data.sku_spec_format)
  549. // 商品SKU格式
  550. if (data.goods_spec_format) data.goods_spec_format = JSON.parse(data.goods_spec_format)
  551. this.keyInput(true)
  552. //拼团倒计时
  553. if (data.end_time - res.timestamp > 0) {
  554. this.groupbuyTimeMachine = {
  555. currentTime: res.timestamp,
  556. startTime: res.timestamp,
  557. endTime: data.end_time
  558. }
  559. } else {
  560. this.$message({
  561. message: '活动已结束',
  562. type: 'warning',
  563. duration: 2000,
  564. onClose: () => {
  565. this.$router.push("/sku/" + this.goodsSkuDetail.sku_id)
  566. }
  567. });
  568. }
  569. this.specBtnRepeat = false
  570. Object.assign(this.goodsSkuDetail, data)
  571. } else {
  572. this.$router.push("/")
  573. }
  574. })
  575. },
  576. changeNum(tag) {
  577. if (this.goodsSkuDetail.stock == 0) return
  578. var stock = this.goodsSkuDetail.stock
  579. //最低购买数量
  580. var min = this.goodsSkuDetail.buy_num
  581. if (this.goodsSkuDetail.buy_num > this.goodsSkuDetail.stock) {
  582. //限购数量大于库存总数取库存
  583. stock = this.goodsSkuDetail.stock
  584. } else {
  585. stock = this.goodsSkuDetail.stock
  586. }
  587. if (tag == "+") {
  588. // 加
  589. if (this.number < stock) {
  590. this.number++
  591. } else {
  592. return
  593. }
  594. } else if (tag == "-") {
  595. // 减
  596. if (this.number > min) {
  597. this.number -= 1
  598. } else {
  599. return
  600. }
  601. }
  602. },
  603. blur() {
  604. let newNumber = parseInt(this.number)
  605. this.number = 0
  606. setTimeout(() => {
  607. this.number = newNumber
  608. }, 0)
  609. },
  610. //输入数量
  611. keyInput(flag, callback) {
  612. setTimeout(() => {
  613. var stock = this.goodsSkuDetail.stock
  614. // 库存为0
  615. if (this.goodsSkuDetail.stock == 0) {
  616. this.number = 0
  617. return
  618. }
  619. // 防止空
  620. if (flag && this.number.length == 0) this.number = 1
  621. // 防止输入0和负数、非法输入
  622. if (flag && (this.number <= 0 || isNaN(this.number))) this.number = 1
  623. if (this.number < this.goodsSkuDetail.buy_num) {
  624. //最低购买数量
  625. this.number = this.goodsSkuDetail.buy_num
  626. }
  627. if (flag) this.number = parseInt(this.number)
  628. if (callback) callback()
  629. }, 0)
  630. },
  631. // 播放回调
  632. onPlayerPlay(player) {},
  633. // 暂停回调
  634. onPlayerPause(player) {},
  635. // 视频播完回调
  636. onPlayerEnded(player) {},
  637. // DOM元素上的readyState更改导致播放停止
  638. onPlayerWaiting(player) {},
  639. // 已开始播放回调
  640. onPlayerPlaying(player) {},
  641. // 当播放器在当前播放位置下载数据时触发
  642. onPlayerLoadeddata(player) {},
  643. // 当前播放位置发生变化时触发。
  644. onPlayerTimeupdate(player) {},
  645. //媒体的readyState为HAVE_FUTURE_DATA或更高
  646. onPlayerCanplay(player) {},
  647. //媒体的readyState为HAVE_ENOUGH_DATA或更高。这意味着可以在不缓冲的情况下播放整个媒体文件。
  648. onPlayerCanplaythrough(player) {},
  649. //播放状态改变回调
  650. playerStateChanged(playerCurrentState) {},
  651. //将侦听器绑定到组件的就绪状态。与事件监听器的不同之处在于,如果ready事件已经发生,它将立即触发该函数。。
  652. playerReadied(player) {},
  653. // 立即购买
  654. buyNow() {
  655. //纠正数量
  656. this.keyInput(true, () => {
  657. if (this.goodsSkuDetail.stock == 0) {
  658. this.$message({
  659. message: "商品已售罄",
  660. type: "warning"
  661. })
  662. return
  663. }
  664. if (this.number.length == 0 || this.number == 0) {
  665. this.$message({
  666. message: "购买数量不能为0",
  667. type: "warning"
  668. })
  669. return
  670. }
  671. // 团购
  672. var data = {
  673. groupbuy_id: this.goodsSkuDetail.groupbuy_id,
  674. sku_id: this.skuId,
  675. num: this.number
  676. }
  677. this.$store.dispatch("order/setGroupbuyOrderCreateData", data)
  678. this.$router.push({
  679. path: "/promotion/groupbuy/payment"
  680. })
  681. })
  682. },
  683. countDownS_cb() {},
  684. countDownE_cb() {
  685. this.groupbuyText = "活动已结束"
  686. this.$message({
  687. message: '团购活动已结束',
  688. type: 'warning',
  689. duration: 2000,
  690. onClose: () => {
  691. this.$router.push("/sku/" + this.goodsSkuDetail.sku_id)
  692. }
  693. });
  694. },
  695. //是否关注
  696. // isFollow() {
  697. // shopIsSubscribe({
  698. // site_id: this.goodsSkuDetail.site_id
  699. // }).then(res => {
  700. // if (res.code == 0) {
  701. // this.hasFollow = res.data
  702. // }
  703. // })
  704. // },
  705. // follow() {
  706. // if (this.hasFollow) {
  707. // deleteShopSubscribe({
  708. // site_id: this.goodsSkuDetail.site_id
  709. // }).then(res => {
  710. // if (res.code == 0 && res.data) {
  711. // this.hasFollow = !this.hasFollow
  712. // this.$message({
  713. // message: "取消成功",
  714. // type: "success"
  715. // })
  716. // }
  717. // })
  718. // } else {
  719. // addShopSubscribe({
  720. // site_id: this.goodsSkuDetail.site_id
  721. // }).then(res => {
  722. // if (res.code == 0 && res.data) {
  723. // this.hasFollow = !this.hasFollow
  724. // this.$message({
  725. // message: "关注成功",
  726. // type: "success"
  727. // })
  728. // }
  729. // })
  730. // }
  731. // },
  732. // 图片加载失败
  733. imageErrorSpec(index) {
  734. this.goodsSkuDetail.sku_images[index] = this.defaultGoodsImage
  735. this.picZoomUrl = this.defaultGoodsImage
  736. },
  737. /**
  738. * 获取地址
  739. * @param {Object} type
  740. * @param {Object} item
  741. * @param {Object} first 是否第一次
  742. */
  743. getAddress(type, item, first, callback) {
  744. let pid = 0
  745. switch (type) {
  746. case 'province':
  747. //加载省
  748. pid = 0
  749. break
  750. case 'city':
  751. //加载市
  752. if (item) {
  753. this.provinceId = item.id
  754. }
  755. pid = this.provinceId
  756. this.cityArr = {}
  757. this.districtArr = {}
  758. break
  759. case 'district':
  760. //加载区县
  761. if (item) this.cityId = item.id
  762. pid = this.cityId
  763. this.districtArr = {}
  764. break
  765. }
  766. if (item) {
  767. if (item.level <= 2) {
  768. let len = item.level;
  769. for (let i = len; i <= 3; i++) {
  770. delete this.selectedAddress['level_' + i];
  771. }
  772. }
  773. this.selectedAddress['level_' + item.level] = item;
  774. }
  775. if (!first) this.$store.commit("app/SET_LOCATION_REGION", this.selectedAddress)
  776. this.$forceUpdate();
  777. if (type == 'community') {
  778. this.hideRegion = true;
  779. setTimeout(() => {
  780. this.hideRegion = false;
  781. }, 10);
  782. return;
  783. }
  784. getArea({
  785. pid: pid
  786. })
  787. .then(res => {
  788. const {
  789. code,
  790. data
  791. } = res;
  792. if (data) {
  793. switch (type) {
  794. case 'province':
  795. //加载省
  796. this.provinceArr = data
  797. break
  798. case 'city':
  799. //加载市
  800. this.cityArr = data
  801. break
  802. case 'district':
  803. //加载区县
  804. this.districtArr = data
  805. break
  806. }
  807. this.currTabAddres = type
  808. if (callback) callback();
  809. }
  810. })
  811. .catch(err => {})
  812. }
  813. }
  814. }