video.vue 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127
  1. <template>
  2. <app-layout>
  3. <view class="page" :style="{ height: height }">
  4. <view class="swiper" :style="containerStyle">
  5. <block v-for="(item, index) in videoList" :key="index">
  6. <video-new
  7. class="video"
  8. :video_id="item.video_id"
  9. :video_url="item.video_url"
  10. :height="height"
  11. :width="width"
  12. :play="item.flag"
  13. :cur_index="cur_index"
  14. :style="{ height: height, width: width }"
  15. ></video-new>
  16. </block>
  17. </view>
  18. <view class="close" @click.stop="close">
  19. <image class="image" src="/static/image/video-close.png"></image>
  20. </view>
  21. <view
  22. class="cover-view-marks"
  23. :style="{ height: height, width: width }"
  24. @click.stop="clickVideo"
  25. @touchmove="ListTouchMove"
  26. @touchend.stop="ListTouchEnd"
  27. @touchstart="ListTouchStart"
  28. >
  29. </view>
  30. <view class="operating ">
  31. <view class="dir-left-nowrap cross-bottom">
  32. <view class="left dir-left-nowrap main-between">
  33. <view class="up-down-goods">
  34. <view class="item" @click="previous">上一件商品</view>
  35. <view class="item down" @click="next">下一件商品</view>
  36. </view>
  37. <view class="goods-list">
  38. <view class="scroll" :style="{bottom: (getEmpty+157) + 'rpx'}" v-show="goodBool">
  39. <view class="scroll-view">
  40. <view class="item-good dir-left-nowrap" @click="routeGo(goods_list[cur_index].page_url)">
  41. <view class="image-view cover-pic">
  42. <image class="cover-pic " :src="goods_list[cur_index] && goods_list[cur_index].cover_pic"></image>
  43. <view>视频同款</view>
  44. </view>
  45. <view v-if="goods_list[cur_index]" class="content dir-top-nowrap main-between">
  46. <view class="name t-omit-two">{{goods_list[cur_index].name}}</view>
  47. <view class="pri-but dir-left-nowrap main-between cross-bottom">
  48. <view>
  49. <view class="dir-left-nowrap">
  50. <!-- 会员价 -->
  51. <view class="member-price" v-if="goods_list[cur_index].is_level == 1 && goods_list[cur_index].is_negotiable != 1">
  52. <app-member-price
  53. :price="goods_list[cur_index].level_price"
  54. :sign="sign"
  55. :theme="sign !== 'gift' ? getTheme : theme"
  56. ></app-member-price>
  57. </view>
  58. <!-- 超级会员卡 -->
  59. <view class="app-sup-vip" v-if="goods_list[cur_index] && goods_list[cur_index].vip_card_appoint.discount">
  60. <app-sup-vip
  61. :discount="goods_list[cur_index] &&goods_list[cur_index].vip_card_appoint.discount"
  62. :is_vip_card_user="goods_list[cur_index].vip_card_appoint.is_vip_card_user"
  63. ></app-sup-vip>
  64. </view>
  65. </view>
  66. <view class="pri">
  67. <text class="price" :style="{'color': sign !== 'gift' ? getTheme.color : ''}" :class="sign === 'gift' ? theme + '-color '+ theme : ''">{{goods_list[cur_index].price_content}}</text>
  68. <text class="original">¥{{goods_list[cur_index].original_price}}</text>
  69. </view>
  70. </view>
  71. <view class="button" @click.stop="specification(goods_list[cur_index])"></view>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. <view class="triangle"></view>
  77. </view>
  78. <image class="image" src="/static/image/video-goods.png" @click="goodBool = !goodBool"></image>
  79. </view>
  80. </view>
  81. <view class="right dir-left-nowrap">
  82. <view class="but index" @click.stop="routeGo('/pages/index/index')">
  83. <view class="icon">
  84. <image class="image" src="/static/image/video-index.png"></image>
  85. </view>
  86. <text>首页</text>
  87. </view>
  88. <view class="but cart" @click.stop="specification(goods_list[cur_index])">
  89. <view class="icon">
  90. <image class="image" src="/static/image/video-card.png"></image>
  91. </view>
  92. <text>加购</text>
  93. </view>
  94. <view class="but" >
  95. <view class="icon">
  96. <image class="image" src="/static/image/video-share.png"></image>
  97. </view>
  98. <text>分享</text>
  99. <!-- #ifdef MP -->
  100. <button class="share" open-type="share">
  101. </button>
  102. <!-- #endif -->
  103. <!-- #ifdef H5 -->
  104. <button class="share" @click="shareUrl">
  105. </button>
  106. <!-- #endif -->
  107. </view>
  108. </view>
  109. </view>
  110. <view class="empty" :style="{'height': getEmpty+'rpx'} ">
  111. </view>
  112. </view>
  113. <view class="attr">
  114. <app-attr ref="attr"
  115. :goods="item"
  116. :select-attr="selectAttr"
  117. :attr-group-list="attrGroup"
  118. :show="show"
  119. :cartShow="cartShow"
  120. :buyText="buyText"
  121. :addText="addText"
  122. :buyClick="buyBool"
  123. :plugin="plugin"
  124. :previewUrl="previewUrl"
  125. :submitUrl="submitUrl"
  126. @buyClick="buyClick"
  127. @attrtap="onAttr"
  128. @attr="attr"
  129. @add="add"
  130. @close="closept"
  131. :is_show_buy="is_show_buy"
  132. :theme="getTheme"
  133. >
  134. <view slot="extra" v-if="sign === 'pintuan'">
  135. <app-pt-attr
  136. v-if="pt"
  137. :groups="item.groups"
  138. :selectGroupAttrId="selectGroupAttrId"
  139. @click="setGroupAttrID"
  140. :theme="getTheme"
  141. ></app-pt-attr>
  142. </view>
  143. </app-attr>
  144. </view>
  145. <view v-if="sign === 'pintuan' && show_pt">
  146. <view class="pintuan dir-left-nowrap" slot="empty-area">
  147. <view class="single box-grow-1 dir-top-nowrap"
  148. :style="{'background-color': getTheme.background_s,'color': getTheme.secondary_text}"
  149. @click="individual"
  150. v-if="item && item.pintuanGoods.is_alone_buy">
  151. <text class="price">
  152. {{singlePrice}}
  153. </text>
  154. <text class="app-text">单独购买</text>
  155. </view>
  156. <view class="tuan box-grow-1 dir-top-nowrap" :style="{'background-color': getTheme.background,'color': getTheme.main_text}" @click="multiplayer">
  157. <text class="price">{{groupPrice}}</text>
  158. <text class="app-text">{{item.groups[set_group_num].groups.people_num}}人拼团</text>
  159. </view>
  160. </view>
  161. </view>
  162. </view>
  163. </app-layout>
  164. </template>
  165. <script>
  166. import {mapGetters, mapState} from 'vuex';
  167. import videoNew from '../../components/page-component/goods/app-goods-video.vue';
  168. import appAttr from '../../components/page-component/app-attr/app-attr.vue';
  169. import appPtAttr from '../../components/page-component/app-pt-attr/app-pt-attr.vue';
  170. import allPay from '../../core/all-pay.js';
  171. export default {
  172. components: {
  173. videoNew,
  174. appPtAttr,
  175. 'app-attr': appAttr,
  176. },
  177. data() {
  178. return {
  179. buyText: '立即购买',
  180. sign: '',
  181. cartShow: 1,
  182. plugin: '',
  183. buyBool: false,
  184. previewUrl: '',
  185. submitUrl: '',
  186. show_pt: false,
  187. pt: true,
  188. selectGroupAttrId: -1,
  189. appAttr: {},
  190. translateX: '10',
  191. height: '667px',
  192. cur_index: null,
  193. width: '',
  194. sysheight: 0,
  195. containerStyle: 'transform:translateY(0px)',
  196. distance: 0,
  197. listTouchStartY: 0,
  198. listTouchDirection: null,
  199. scroll: false,
  200. videoList: [],
  201. clicktime: 0,
  202. goodBool: false,
  203. goods_list: [],
  204. page: 1,
  205. goods_id: 0,
  206. show: 0,
  207. item: null,
  208. selectAttr: {},
  209. attrGroup: null,
  210. ne: 0,
  211. pre: 0,
  212. is_show_buy: true,
  213. is_share: 0,//社交送礼用的
  214. addText: '',
  215. ptAttr: {},
  216. ptId: 0,
  217. getResult: null,
  218. han: null
  219. };
  220. },
  221. computed: {
  222. ...mapGetters('iPhoneX', {
  223. getEmpty: 'getEmpty'
  224. }),
  225. ...mapGetters('mallConfig', {
  226. getTheme: 'getTheme',
  227. }),
  228. ...mapState('gift',{
  229. theme: state => state.theme,
  230. }),
  231. groupPrice: function() {
  232. if(this.item) {
  233. if (!this.$validation.isEmpty(this.selectAttr)) {
  234. if (this.pt) {
  235. if (this.item.level_show === 1) {
  236. if (this.selectAttr.price_member === 0) {
  237. return '免费';
  238. } else {
  239. return `¥${this.selectAttr.price_member}`;
  240. }
  241. } else {
  242. if (Number(this.selectAttr.price) === 0) {
  243. return '免费';
  244. } else {
  245. return `¥${this.selectAttr.price}`;
  246. }
  247. }
  248. } else {
  249. let attr = this.item.groups[this.set_group_num].attr;
  250. for (let i = 0; i < attr.length; i++) {
  251. if (attr[i].sign_id === this.selectAttr.sign_id) {
  252. if (this.item.level_show === 1) {
  253. if (attr[i].price_member === 0) {
  254. return '免费';
  255. } else {
  256. return `¥${attr[i].price_member}`;
  257. }
  258. } else {
  259. if (Number(attr[i].price) === 0) {
  260. return '免费';
  261. } else {
  262. return `¥${attr[i].price}`;
  263. }
  264. }
  265. }
  266. }
  267. }
  268. } else {
  269. if (this.item.level_show === 1) {
  270. if (Number(this.item.price_member_min) === 0) {
  271. return '免费';
  272. } else {
  273. return `¥${this.item.price_member_min}`;
  274. }
  275. } else {
  276. if (Number(this.item.price) === 0) {
  277. return '免费';
  278. } else {
  279. return `¥${this.item.price}`
  280. }
  281. }
  282. }
  283. }
  284. },
  285. set_group_num() {
  286. if(this.item && this.item.groups) {
  287. for (let i = 0; i < this.item.groups.length; i++) {
  288. if (this.item.groups[i].groups.id == this.selectGroupAttrId) {
  289. return i;
  290. }
  291. }
  292. }
  293. },
  294. singlePrice: function() {
  295. if(this.item) {
  296. if (!this.$validation.isEmpty(this.selectAttr)) {
  297. for (let i = 0; i < this.ptAttr.length; i++) {
  298. if (this.ptAttr[i].sign_id === this.selectAttr.sign_id) {
  299. if (this.item.level_show === 1) {
  300. if (Number(this.ptAttr[i].price_member) === 0) {
  301. return '免费';
  302. } else {
  303. return `¥${this.ptAttr[i].price_member}`;
  304. }
  305. } else {
  306. if (Number(this.ptAttr[i].price) === 0) {
  307. return '免费';
  308. } else {
  309. return `¥${this.ptAttr[i].price}`;
  310. }
  311. }
  312. }
  313. }
  314. } else {
  315. if (this.item.level_show === 1) {
  316. if (Number(this.item.price_member_min) === 0) {
  317. return '免费';
  318. } else {
  319. return `¥${this.item.price_member_min}`;
  320. }
  321. } else {
  322. if (Number(this.item.price) === 0) {
  323. return '免费';
  324. } else {
  325. return `¥${this.item.price}`
  326. }
  327. }
  328. }
  329. }
  330. },
  331. },
  332. onLoad(options) { this.$commonLoad.onload(options);
  333. this.goods_id = options.goods_id;
  334. this.sign = options.sign;
  335. this.is_share = options.is_share;
  336. switch (this.sign) {
  337. case "advance":
  338. this.cartShow = 0;
  339. this.buyText = '支付定金';
  340. this.buyBool = true;
  341. break;
  342. case "booking":
  343. this.cartShow = 0;
  344. this.buyText = '立即预约';
  345. this.plugin = 'booking';
  346. this.submitUrl = this.$api.book.order_submit;
  347. this.previewUrl = this.$api.book.order_preview;
  348. break;
  349. case "miaosha":
  350. this.addText = '加入购物车';
  351. this.submitUrl = this.$api.miaosha.order_submit;
  352. this.previewUrl = this.$api.miaosha.order_preview;
  353. break;
  354. case "pintuan":
  355. this.$request({
  356. url: this.$api.pt.detail,
  357. data: {
  358. id: this.goods_id,
  359. group_id: 0,
  360. }
  361. }).then((res) => {
  362. this.item = res.data.detail;
  363. this.cartShow = res.data.detail.pintuanGoods.is_alone_buy;
  364. this.ptAttr = JSON.parse(JSON.stringify(res.data.detail.attr));
  365. this.ptId = JSON.parse(JSON.stringify(res.data.detail.id));
  366. this.selectGroupAttrId = this.item.groups[0].groups.id;
  367. this.item.attr = this.item.groups[0].attr;
  368. this.item.id = this.item.groups[0].groups.goods_id;
  369. });
  370. break;
  371. case "integral_mall":
  372. this.cartShow = 0;
  373. this.buyText = '立即兑换';
  374. this.submitUrl = this.$api.integral_mall.order_submit;
  375. this.previewUrl = this.$api.integral_mall.order_preview;
  376. break;
  377. case "step":
  378. this.cartShow = 0;
  379. this.buyText = '立即兑换';
  380. this.submitUrl = this.$api.step.order_submit;
  381. this.previewUrl = this.$api.step.order_preview;
  382. break;
  383. case "gift":
  384. this.cartShow = 0;
  385. this.buyBool = true;
  386. this.buyText = '加入礼包';
  387. this.$request({
  388. url: this.$api.gift.config,
  389. method: 'get',
  390. }).then((res) => {
  391. if (res.code === 0) {
  392. this.$store.commit('gift/setTheme', Number(res.data.theme.id));
  393. }
  394. });
  395. break;
  396. case "mch":
  397. this.addText = '加入购物车';
  398. this.submitUrl = this.$api.mch.order_submit;
  399. this.previewUrl = this.$api.mch.order_preview;
  400. break;
  401. case "pick":
  402. this.addText = '加入凑单池';
  403. this.is_show_buy=false;
  404. break;
  405. case "exchange":
  406. this.cartShow = 0;
  407. this.submitUrl = this.$api.exchange.order_submit;
  408. this.previewUrl = this.$api.exchange.order_preview;
  409. break;
  410. case "community":
  411. this.addText = '加入购物车';
  412. this.is_show_buy=false;
  413. break;
  414. default:
  415. this.addText = '加入购物车';
  416. break;
  417. }
  418. this.getVideo(options.goods_id);
  419. let res = uni.getSystemInfoSync();
  420. this.height = `${res.windowHeight}px`;
  421. this.width = `${res.windowWidth}px`;
  422. this.sysheight = res.windowHeight;
  423. },
  424. onHide() {
  425. this.videoList[this.cur_index].flag = false;
  426. clearTimeout(this.getResult);
  427. },
  428. onShow() {
  429. if (this.cur_index !== null) {
  430. this.videoList[this.cur_index].flag = true;
  431. }
  432. },
  433. methods: {
  434. buyClick(data) {
  435. allPay(data, this.sign, this, this.goods_list[this.cur_index]);
  436. },
  437. submit() {
  438. let goods = this.item;
  439. let number = this.appAttr.number;
  440. let select_attr = this.selectAttr;
  441. if (!select_attr) {
  442. uni.showModal({
  443. title: '提示',
  444. content: '请先选择规格',
  445. showCancel: false
  446. });
  447. return false;
  448. }
  449. if (number <= 0) {
  450. uni.showModal({
  451. title: '提示',
  452. content: '商品数量不能为0',
  453. showCancel: false
  454. });
  455. return false;
  456. }
  457. if (!goods) {
  458. return false;
  459. }
  460. return true;
  461. },
  462. onAttr(goods) {
  463. this.selectAttr = goods;
  464. },
  465. specification(goods) {
  466. this.attrGroup = goods.attr_groups;
  467. this.item = JSON.parse(JSON.stringify(goods));
  468. if (this.sign === 'pintuan') {
  469. this.pt = true;
  470. this.cartShow = goods.pintuanGoods.is_alone_buy;
  471. this.show_pt = true;
  472. this.ptAttr = JSON.parse(JSON.stringify(goods.attr));
  473. this.ptId = JSON.parse(JSON.stringify(goods.id));
  474. this.selectGroupAttrId = goods.groups[0].groups.id;
  475. this.item.id = goods.groups[0].groups.goods_id;
  476. this.item.attr = goods.groups[0].attr;
  477. }
  478. this.show = Math.random();
  479. },
  480. setGroupAttrID(item) {
  481. this.selectGroupAttrId = item.groups.id;
  482. this.selectAttr = null;
  483. this.item.attr = item.attr;
  484. this.item.id = item.groups.goods_id;
  485. },
  486. attr(data) {
  487. this.appAttr = data;
  488. },
  489. buy() {
  490. if (!this.submit()) {
  491. return false;
  492. }
  493. let goods = this.item;
  494. let number = this.appAttr.number;
  495. let select_attr = this.selectAttr;
  496. let goods_attr_id = select_attr.id;
  497. let attr = [];
  498. for (let i in select_attr.attr_list) {
  499. attr.push({
  500. attr_id: select_attr.attr_list[i].attr_id,
  501. attr_group_id: select_attr.attr_list[i].attr_group_id,
  502. });
  503. }
  504. let mch_list = [];
  505. let mch = {
  506. mch_id: goods.mch_id ? goods.mch_id : 0,
  507. pintuan_order_id: 0,
  508. pintuan_group_id: 0,
  509. goods_list: []
  510. };
  511. mch.goods_list.push({
  512. id: goods.id,
  513. attr: attr,
  514. num: number,
  515. cat_id: 0,
  516. goods_attr_id: goods_attr_id
  517. });
  518. mch_list.push(mch);
  519. uni.navigateTo({
  520. url: `/pages/order-submit/order-submit?mch_list=${JSON.stringify(mch_list)}&preview_url=${encodeURIComponent(this.$api.pt.order_preview)}&submit_url=${encodeURIComponent(this.$api.pt.order_submit)}`
  521. });
  522. },
  523. individual() {
  524. if (this.pt) {
  525. this.pt = false;
  526. // this.item.attr = this.ptAttr;
  527. this.$set(this.item, 'attr', this.ptAttr);
  528. this.$set(this.item, 'id', this.ptId);
  529. // this.item.id = this.ptId;
  530. this.selectAttr = null;
  531. } else {
  532. if (Object.keys(this.selectAttr).length === 0) {
  533. uni.showToast({
  534. title: '请选择规格',
  535. icon: "none"
  536. })
  537. } else {
  538. this.buy();
  539. }
  540. }
  541. },
  542. closept() {
  543. this.selectAttr = null;
  544. this.$set(this.item, 'attr', this.ptAttr);
  545. this.$set(this.item, 'id', this.ptId);
  546. },
  547. multiplayer() {
  548. if (this.pt) {
  549. if (this.selectAttr && Object.keys(this.selectAttr).length === 0) {
  550. uni.showToast({
  551. title: '请选择规格',
  552. icon: "none"
  553. })
  554. } else if (this.selectAttr && Object.keys(this.selectAttr).length > 0) {
  555. let mch_id = this.item.mch_id;
  556. let mch_list = [];
  557. let goods = {
  558. id: this.item.id,
  559. attr: [],
  560. num: this.appAttr.number,
  561. goods_attr_id: this.selectAttr.id,
  562. cart_id: 0,
  563. };
  564. for (let i = 0; i < this.selectAttr.attr_list.length; i++) {
  565. let attr = {
  566. attr_id: this.selectAttr.attr_list[i].attr_id,
  567. attr_group_id: this.selectAttr.attr_list[i].attr_group_id,
  568. };
  569. goods.attr.push(attr);
  570. }
  571. mch_list.push({
  572. mch_id: mch_id,
  573. pintuan_order_id: 0,
  574. pintuan_group_id: this.selectGroupAttrId,
  575. goods_list: [goods],
  576. });
  577. uni.navigateTo({
  578. url: `/pages/order-submit/order-submit?mch_list=${JSON.stringify(mch_list)}&preview_url=${encodeURIComponent(this.$api.pt.order_preview)}&submit_url=${encodeURIComponent(this.$api.pt.order_submit)}&order_page_url=/plugins/pt/order/order&plugin=pt`
  579. });
  580. }
  581. } else {
  582. this.selectAttr = null;
  583. this.pt = true;
  584. this.selectGroupAttrId = this.item.groups[0].groups.id;
  585. this.item.attr = this.item.groups[0].attr;
  586. this.item.id = this.item.groups[0].groups.goods_id;
  587. }
  588. },
  589. async getVideo() {
  590. const res = await this.$request({
  591. url: this.$api.goods.goods_video_list,
  592. method: 'get',
  593. data: {
  594. goodsId: this.goods_id,
  595. page: this.page,
  596. limit: 2
  597. }
  598. });
  599. if (res.code === 0) {
  600. let data = res.data.list;
  601. for (let item of data) {
  602. this.videoList.push({
  603. video_id: item.id,
  604. video_url: item.video_url,
  605. flag: false,
  606. });
  607. this.goods_list.push(item);
  608. }
  609. if (this.cur_index == null) this.cur_index = 0;
  610. this.$nextTick().then(() => {
  611. this.videoList[this.cur_index].flag = true;
  612. });
  613. }
  614. },
  615. routeGo(data) {
  616. uni.navigateTo({
  617. url: data,
  618. })
  619. },
  620. close() {
  621. let url = this.goods_list[this.cur_index].page_url;
  622. if (this.is_share) url = url + '&is_share=1';
  623. uni.redirectTo({
  624. url,
  625. });
  626. },
  627. clickVideo(e) {
  628. this.goodBool = false;
  629. if(this.clicktime > 0 && e.timeStamp - this.clicktime < 200){
  630. clearTimeout(this.han);
  631. }else{
  632. let _this = this;
  633. this.han = setTimeout(function() {
  634. _this.videoList[_this.cur_index].flag = !_this.videoList[_this.cur_index].flag;
  635. }, 200);
  636. }
  637. this.clicktime = e.timeStamp;
  638. return;
  639. },
  640. ListTouchStart(e) {
  641. this.listTouchStartY = e.changedTouches[0].pageY;
  642. },
  643. ListTouchMove(e) {
  644. this.listTouchDirection = this.listTouchStartY - e.changedTouches[0].pageY > 10 ? -1 : 0;
  645. this.listTouchDirection = e.changedTouches[0].pageY - this.listTouchStartY > 10 ? 1 : this.listTouchDirection;
  646. const distance = this.distance + e.changedTouches[0].pageY - this.listTouchStartY;
  647. if (distance > 0) return;
  648. if (Math.abs(this.listTouchStartY - e.changedTouches[0].pageY) < 2) {
  649. this.listTouchDirection = null;
  650. }
  651. },
  652. ListTouchEnd(e) {
  653. this.handelVideo(e);
  654. },
  655. handelVideo(){
  656. if (this.cur_index == 0 && this.listTouchDirection == 1) {
  657. return;
  658. }
  659. this.translateX = 10;
  660. if (this.scroll) return;
  661. if (!this.listTouchDirection) {
  662. return;
  663. }
  664. const destination = this.listTouchDirection * this.sysheight + this.distance;
  665. if (destination > 0 || destination < -this.sysheight * (this.videoList.length - 1)) return;
  666. for (let item of this.videoList) {
  667. item.flag = false;
  668. }
  669. this.animate(destination, this.listTouchDirection);
  670. this.cur_index = this.cur_index - this.listTouchDirection;
  671. this.videoList[this.cur_index].flag = true;
  672. //移动到最后一个加载新的列表
  673. if (this.videoList.length == this.cur_index + 1) {
  674. this.page++;
  675. this.getVideo();
  676. }
  677. this.listTouchDirection = null;
  678. },
  679. animate(des, direc) {
  680. let { distance } = this;
  681. return new Promise((resolve, reject) => {
  682. this.scroll = true;
  683. const temp = setInterval(() => {
  684. if ((direc === -1 && des < distance) || (direc === 1 && des > distance)) {
  685. distance += 100 * direc;
  686. this.containerStyle = `transform:translateY(${distance}px)`;
  687. } else {
  688. clearInterval(temp);
  689. distance = des;
  690. this.distance = des;
  691. this.containerStyle = `transform:translateY(${distance}px)`;
  692. this.scroll = false;
  693. resolve();
  694. }
  695. }, 20);
  696. });
  697. },
  698. previous() {
  699. if (this.cur_index === 0) return;
  700. for (let item of this.videoList) {
  701. item.flag = false;
  702. }
  703. this.distance =this.distance + this.sysheight;
  704. this.cur_index = this.cur_index - 1;
  705. this.containerStyle = `transform:translateY(${this.distance}px)`;
  706. clearTimeout(this.pre);
  707. this.pre = setTimeout(() => {
  708. this.videoList[this.cur_index].flag = true;
  709. }, 300);
  710. },
  711. async add(data, number) {
  712. if (this.sign === 'pick') {
  713. if (this.item.activity_id === 0) {
  714. uni.showToast({
  715. title: '活动不存在',
  716. icon: 'none'
  717. });
  718. } else {
  719. const e = await this.$request({
  720. url: this.$api.pick.add,
  721. data: {
  722. goods_id: data.goods_id,
  723. attr: data.id,
  724. num: number,
  725. pick_activity_id: this.item.activity_id
  726. }
  727. });
  728. if (e.code === 0) {
  729. uni.showToast({
  730. title: '加入成功',
  731. icon: 'none'
  732. });
  733. }
  734. }
  735. } else if (this.sign === 'community') {
  736. let { id, goods_id } = data;
  737. this.$request({
  738. url: this.$api.community.cart_add,
  739. data: {
  740. activity_id: this.item.id,
  741. goods_id: goods_id,
  742. goods_attr_id: id,
  743. num: number
  744. },
  745. method: 'post'
  746. }).then(response => {
  747. if (response.code === 0) {
  748. this.addResult(response.data.queue_id, response.data.token);
  749. }
  750. });
  751. }
  752. },
  753. addResult(queue_id, token) {
  754. this.$request({
  755. url: this.$api.community.cart_result,
  756. method: 'post',
  757. data: {
  758. queue_id: queue_id,
  759. token: token,
  760. },
  761. }).then(response => {
  762. if (response.code === 0) {
  763. if (response.data && response.data.retry === 1) {
  764. this.getResult = setTimeout(() => {
  765. this.addResult(queue_id, token);
  766. }, 1000);
  767. } else {
  768. this.attrShow = 0;
  769. uni.hideLoading();
  770. uni.showToast({
  771. title: '添加成功',
  772. duration: 1000
  773. });
  774. }
  775. } else {
  776. uni.hideLoading();
  777. uni.showToast({
  778. title: response.msg,
  779. icon: 'none',
  780. duration: 1000
  781. });
  782. }
  783. });
  784. },
  785. next() {
  786. if (this.cur_index + 1 === this.videoList.length) {
  787. uni.showToast({
  788. title: '无更多视频',
  789. icon: 'none'
  790. });
  791. return
  792. }
  793. this.distance = this.distance - this.sysheight;
  794. this.containerStyle = `transform:translateY(${this.distance}px)`;
  795. clearTimeout(this.ne);
  796. this.ne = setTimeout(() => {
  797. this.videoList[this.cur_index].flag = false;
  798. this.cur_index = this.cur_index + 1;
  799. this.videoList[this.cur_index].flag = true;
  800. });
  801. if (this.videoList.length < this.cur_index + 1) {
  802. this.page++;
  803. this.getVideo();
  804. }
  805. },
  806. // #ifdef H5
  807. shareUrl() {
  808. let goods = this.goods_list[this.cur_index];
  809. let params = {
  810. id: goods.id,
  811. mch_id: goods.mch_id
  812. }
  813. if (goods.sign === 'integral_mall') {
  814. delete params.id;
  815. params.goods_id = goods.id
  816. }
  817. this.$shareAppMessage({
  818. title: goods.app_share_title ? goods.app_share_title : goods.name,
  819. imageUrl: goods.app_share_pic ? goods.app_share_pic : goods.cover_pic,
  820. path: goods.page_url.split('?')[0],
  821. params: params
  822. });
  823. }
  824. // #endif
  825. },
  826. // #ifdef MP
  827. onShareAppMessage() {
  828. let goods = this.goods_list[this.cur_index];
  829. let params = {
  830. id: goods.id,
  831. mch_id: goods.mch_id
  832. }
  833. if (goods.sign === 'integral_mall') {
  834. delete params.id;
  835. params.goods_id = goods.id
  836. }
  837. return this.$shareAppMessage({
  838. title: goods.app_share_title ? goods.app_share_title : goods.name,
  839. imageUrl: goods.app_share_pic ? goods.app_share_pic : goods.cover_pic,
  840. path: goods.page_url.split('?')[0],
  841. params: params
  842. });
  843. },
  844. // #endif
  845. watch: {
  846. appAttr: {
  847. handler(data) {
  848. if (data.display === 'none') {
  849. this.show_pt = false;
  850. }
  851. }
  852. }
  853. },
  854. onUnload() {
  855. clearTimeout(this.getResult);
  856. }
  857. };
  858. </script>
  859. <style lang="scss">
  860. @import '../../static/css/gift.scss';
  861. .empty {
  862. width: #{750upx};
  863. }
  864. .page {
  865. flex: 1;
  866. overflow: hidden;
  867. background-color: #000;
  868. }
  869. .operating {
  870. position: fixed;
  871. bottom: 0;
  872. left: 0;
  873. width: 100%;
  874. z-index: 1402;
  875. }
  876. .left {
  877. margin-left: #{26upx};
  878. width: #{410upx};
  879. }
  880. .right {
  881. margin-right: #{26upx};
  882. }
  883. .attr {
  884. position: fixed;
  885. bottom: 0;
  886. left: 0;
  887. z-index: 1403;
  888. }
  889. .up-down-goods {
  890. .item {
  891. width: #{266upx};
  892. height: #{60upx};
  893. border-radius: #{16upx};
  894. background-color: rgba(51,51,51,.4);
  895. color: #ffffff;
  896. font-size: #{24upx};
  897. line-height: #{60upx};
  898. text-align: center;
  899. }
  900. .down {
  901. margin-top: #{12upx};
  902. }
  903. }
  904. .goods-list {
  905. width: #{124upx};
  906. height: #{124upx};
  907. border-radius: #{62upx};
  908. background-color: rgba(51,51,51,.4);
  909. margin-left: #{20upx};
  910. position: relative;
  911. .image {
  912. width: #{68upx};
  913. height: #{78upx};
  914. position: absolute;
  915. top: 50%;
  916. left: 50%;
  917. transform: translate(-50%, -50%);
  918. }
  919. }
  920. .index {
  921. margin-left: #{20upx};
  922. }
  923. .cart {
  924. margin: #{0 30upx};
  925. }
  926. .but {
  927. text-align: center;
  928. position: relative;
  929. .icon {
  930. width: #{70upx};
  931. height: #{70upx};
  932. border-radius: #{35upx};
  933. background-color: rgba(51,51,51,.4);
  934. position: relative;
  935. }
  936. .image {
  937. width: #{38upx};
  938. height: #{36upx};
  939. position: absolute;
  940. top: 50%;
  941. left: 50%;
  942. transform: translate(-50%, -50%);
  943. }
  944. text {
  945. color: #ffffff;
  946. font-size: #{24upx};
  947. line-height: 1;
  948. }
  949. }
  950. .share {
  951. background: transparent;
  952. border: none;
  953. border-radius: 0;
  954. padding:0;
  955. position: absolute;
  956. top: 0;
  957. left: 0;
  958. width: 100%;
  959. height: 100%;
  960. }
  961. .scroll {
  962. width: #{690upx};
  963. height: #{240upx};
  964. position: fixed;
  965. left: 50%;
  966. bottom: #{157upx};
  967. transform: translate(-50%, 0%);
  968. }
  969. .scroll-view {
  970. height: calc(100% - #{23upx});
  971. background-color: #ffffff;
  972. border-radius: #{16upx};
  973. padding: #{0 25upx};
  974. .item-good {
  975. padding-top: #{25upx};
  976. .image-view {
  977. position: relative;
  978. >view {
  979. width: #{150upx};
  980. height: #{30upx};
  981. line-height: #{30upx};
  982. position: absolute;
  983. bottom: 0;
  984. font-size: #{18upx};
  985. color: #ffffff;
  986. text-align: center;
  987. background: linear-gradient(to left, #ffcb00, #ff9600);
  988. }
  989. }
  990. }
  991. .cover-pic {
  992. width: #{150upx};
  993. height: #{150upx};
  994. }
  995. .content {
  996. width: calc(100% - #{150upx});
  997. min-height: #{150upx};
  998. margin-bottom: #{25upx};
  999. padding-left: #{25upx};
  1000. }
  1001. .name {
  1002. line-height: #{32upx};
  1003. font-size: #{24upx};
  1004. color: #303030;
  1005. margin-top: #{8upx};
  1006. }
  1007. .pri-but {
  1008. >.button {
  1009. width: #{50upx};
  1010. height: #{50upx};
  1011. background-image: url("../../static/image/icon/add-to.png");
  1012. background-size: 100% 100%;
  1013. background-repeat: no-repeat;
  1014. margin: #{0 4upx 0 0};
  1015. border-radius: #{25rpx};
  1016. background-color: transparent;
  1017. }
  1018. .pri {
  1019. line-height: #{21upx};
  1020. margin-top: #{9upx};
  1021. }
  1022. .price {
  1023. font-size: #{21upx};
  1024. line-height: 1;
  1025. }
  1026. .original {
  1027. color: #999999;
  1028. font-size: #{17upx};
  1029. line-height: 1;
  1030. text-decoration: line-through;
  1031. margin-left: #{15upx};
  1032. }
  1033. }
  1034. .member-price {
  1035. margin-right: #{12upx};
  1036. }
  1037. }
  1038. .triangle {
  1039. width: #{40upx};
  1040. border-top: #{23upx} solid #ffffff;
  1041. border-bottom: #{23upx} solid transparent;
  1042. border-left: #{23upx} solid transparent;
  1043. border-right: #{23upx} solid transparent;
  1044. position: absolute;
  1045. left: 50%;
  1046. transform: translateX(-50%);
  1047. }
  1048. .close {
  1049. position: fixed;
  1050. top: 26upx;
  1051. right: #{26upx};
  1052. width: #{70upx};
  1053. height: #{70upx};
  1054. z-index: 1406;
  1055. border-radius: #{35upx};
  1056. background-color: rgba(51,51,51,.4);
  1057. .image {
  1058. width: #{26upx};
  1059. height: #{26upx};
  1060. position:absolute;
  1061. left: 50%;
  1062. top: 50%;
  1063. transform: translate(-50%, -50%);
  1064. }
  1065. }
  1066. .swiper {
  1067. position: relative;
  1068. }
  1069. .cover-view-marks {
  1070. position: fixed;
  1071. top: 0;
  1072. right: 0;
  1073. z-index: 1401;
  1074. }
  1075. .video {
  1076. width: 100%;
  1077. height: 100%;
  1078. position: relative;
  1079. }
  1080. .pintuan {
  1081. width: #{750upx};
  1082. height: #{110upx};
  1083. padding: #{20rpx} #{24rpx};
  1084. position: fixed;
  1085. bottom: 0;
  1086. left: 0;
  1087. z-index: 1500;
  1088. .single {
  1089. border-top-left-radius: 35rpx;
  1090. border-bottom-left-radius: 35rpx;
  1091. text-align: center;
  1092. font-size: 22upx;
  1093. }
  1094. .tuan {
  1095. border-top-right-radius: 35rpx;
  1096. border-bottom-right-radius: 35rpx;
  1097. text-align: center;
  1098. font-size: 22upx;
  1099. }
  1100. }
  1101. .buy {
  1102. color: #ffffff;
  1103. }
  1104. </style>