1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393 |
- const app = getApp()
- var http = require('../../utils/http.js');
- var config = require('../../utils/config.js');
- var util = require('../../utils/util.js');
- Page({
-
- data: {
- shopId: 1,
- shopName: '',
- picDomain: config.picDomain,
- indicatorDots: true,
- indicatorColor: '#f2f2f2',
- indicatorActiveColor: '#04358D',
- isAuthInfo: true,
- autoplay: true,
- interval: 3000,
- duration: 1000,
- prodNum: 1,
- totalCartNum: 0,
- groupActivityId: 0,
- pic: "",
- imgs: '',
- prodName: '',
- price: 0,
- actPrice: 0,
- content: '',
- prodId: 0,
- brief: '',
- skuId: 0,
- popupShow: false,
-
- loadCouponIds: false,
- skuShow: false,
- skuGroupShow: false,
- commentShow: false,
- couponList: [],
- skuList: [],
- skuGroup: {},
- findSku: true,
- defaultSku: undefined,
- detaultGroupSku: undefined,
- selectedProp: [],
- selectedPropObj: {},
- selectedProperties: "",
- propKeys: [],
- allProperties: [],
- prodCommData: {},
- prodCommPage: {
- current: 0,
- pages: 0,
- records: []
- },
- littleCommPage: [],
- evaluate: -1,
- isCollection: false,
- shareShow: false,
- isDist: false,
- isDistProd: false,
- distributionCardNo: "",
- wxCodeShow: false,
- shareWxCode: "",
- groupActivity: {},
- endOfGroupTime: {},
- joinGroupList: [],
- skuShowType: 0,
- totalStocks: 0,
- hasMaxNum: false,
- maxNum: 0,
- joinGroupListTimer: '',
- endOfGroupTimer: '',
- scene: '',
- prodDiscountList: [],
- phoneNumber: '',
- showBacktop: false,
- showDiscountPopup: false,
- videoContext: '',
- isPlaying: false,
- currentSwiper: 0,
- },
-
- onLoad: function (options) {
- console.log(options)
-
- if (options.scene) {
- this.setData({
- scene: options.scene,
- })
- this.getContent()
- }
-
- if (options.prodid) {
- this.setData({
- prodId: options.prodid,
- });
- this.executionFunction()
- }
- if (options.cardno && options.type == 2) {
-
- this.setData({
- distributionCardNo: options.cardno,
- })
- }
- this.getCartCount()
- },
-
- executionFunction: function () {
-
- this.getProdCommData();
-
- this.getLittleProdComm();
-
- this.getCollection();
-
- this.getDistInfo();
-
- this.getProdInfo();
-
- this.getPordDiscountList()
- },
-
- getContent: function () {
- http.request({
- url: "/qrcodeTicket/getContent",
- method: "GET",
- data: {
- ticket: this.data.scene
- },
- callBack: (res) => {
- console.log(res)
- var content = JSON.parse(res.content);
- var ids = JSON.parse(content.content)
- if (res.type == 1) {
- this.setData({
- prodId: ids.prodId,
- groupActivityId: ids.groupActivityId
- })
- this.executionFunction()
- } else if (res.type == 2) {
- this.setData({
- prodId: ids.shareProdId,
- distributionCardNo: ids.cardNo
- })
- this.executionFunction()
- }
- }
- })
- },
-
- onUnload: function () {
- clearTimeout(this.data.endOfGroupTimer)
- },
-
-
-
-
-
-
-
-
-
-
-
-
-
- getDistInfo() {
-
- http.request({
- url: "/p/distribution/distributionBasicSet/canDistribution",
- method: "GET",
- dontTrunLogin: true,
-
-
-
- callBack: (res) => {
- if (res == 1) {
- this.getIsDistInfo();
- }
- }
- })
- },
-
- getIsDistInfo() {
- http.request({
- url: "/p/distribution/user/distributionUserInfo",
- method: "GET",
- callBack: (res) => {
- console.log('是否分销员', res)
- if (res && res.state == 1) {
- this.setData({
- isDist: true
- });
- this.getIsDistProd();
- wx.setStorageSync("distCardNo", res.cardNo);
- }
- }
- })
- },
-
- getIsDistProd() {
- http.request({
- url: "/p/distribution/prod/isDistributionProd",
- method: "GET",
- data: {
- prodId: this.data.prodId,
- },
- callBack: (res) => {
- console.log('是否分销商品', res)
- if (res) {
- this.setData({
- isDistProd: true
- });
- }
- }
- })
- },
-
- getCollection() {
- wx.showLoading();
- var params = {
- url: "/p/user/collection/isCollection",
- method: "GET",
- dontTrunLogin: true,
- data: {
- prodId: this.data.prodId
- },
- callBack: (res) => {
- this.setData({
- isCollection: res
- })
- wx.hideLoading();
- }
- };
- http.request(params);
- },
-
- addOrCannelCollection() {
- util.checkAuthInfo(() => {
- var params = {
- url: "/p/user/collection/addOrCancel",
- method: "POST",
- data: this.data.prodId,
- callBack: (res) => {
- this.setData({
- isCollection: !this.data.isCollection
- })
- wx.showToast({
- title: res ? '已添加收藏' : '已取消收藏',
- duration: 3000,
- icon: 'none',
- })
- setTimeout(() => {
- wx.hideToast()
- }, 3000)
- }
- };
- http.request(params);
- })
- },
-
- getProdInfo() {
- wx.showLoading();
- var params = {
- url: "/prod/prodInfo",
- method: "GET",
- data: {
- prodId: this.data.prodId,
-
- },
- callBack: (res) => {
- let pic = ''
- var imgStrs = res.imgs;
- var imgs = imgStrs.split(",");
- var content = util.formatHtml(res.content);
- pic = res.pic.split(',')
- res.pic = pic[0]
- this.setData({
- imgs: imgs,
- content: content,
- price: res.price,
- prodName: res.prodName,
- prodId: res.prodId,
- brief: res.brief,
- totalStocks: res.totalStocks,
-
- skuList: res.skuList,
- pic: res.pic,
- shopId: res.shopId,
- video: res.video,
- prodType: res.prodType
- });
- if (res.video) {
- this.getVideoInfo()
- }
-
- if (res.prodType === 1) {
- this.setData({
- groupActivityId: res.activityId
- });
- this.getGroupActivity();
- this.getJoinGroupList();
- }
-
- this.getCouponList();
-
- this.groupSkuProp(res.skuList);
- this.getShopInfo();
- wx.hideLoading();
- },
- errCallBack: (err) => {
- console.log(err)
- if (err.statusCode == 400) {
- wx.showModal({
- title: '提示',
- content: err.data,
- showCancel: false,
- success: (res) => {
- if (res.confirm) {
- wx.navigateBack({
- delta: 1
- })
- }
- }
- })
- }
- }
- };
- http.request(params);
- },
-
- getShopInfo() {
- http.request({
- url: "/shop/headInfo",
- method: "GET",
- data: {
- shopId: this.data.shopId,
- },
- callBack: (res) => {
- this.setData({
- shopName: res.shopName,
- shopLogo: res.shopLogo,
- phoneNumber: res.tel
- })
- }
- })
- },
- getProdCommData() {
- http.request({
- url: "/prod/prodCommData",
- method: "GET",
- data: {
- prodId: this.data.prodId,
- },
- callBack: (res) => {
- this.setData({
- prodCommData: res
- })
- }
- })
- },
-
- getLittleProdComm() {
- if (this.data.prodCommPage.records.length) {
- return;
- }
- this.getProdCommPage();
- },
- getMoreCommPage(e) {
- this.getProdCommPage();
- },
-
- getProdCommPage(e) {
- if (e) {
- if (e.currentTarget.dataset.evaluate === this.data.evaluate) {
- return;
- }
- this.setData({
- prodCommPage: {
- current: 0,
- pages: 0,
- records: []
- },
- evaluate: e.currentTarget.dataset.evaluate
- })
- }
- http.request({
- url: "/prod/prodCommPageByProd",
- method: "GET",
- data: {
- prodId: this.data.prodId,
- size: 10,
- current: this.data.prodCommPage.current + 1,
- evaluate: this.data.evaluate
- },
- callBack: (res) => {
- res.records.forEach(item => {
- if (item.pics) {
- item.pics = item.pics.split(',')
- }
- })
- let records = this.data.prodCommPage.records
- records = records.concat(res.records)
- this.setData({
- prodCommPage: {
- current: res.current,
- pages: res.pages,
- records: records
- }
- })
-
- if (!this.data.littleCommPage.length) {
- this.setData({
- littleCommPage: records.slice(0, 2)
- })
- }
- }
- })
- },
-
- clickImg: function (e) {
- const current = e.currentTarget.dataset.index
- const pics = e.currentTarget.dataset.pics
- wx.previewImage({
- current: pics[current],
- urls: pics
- })
- },
- getCouponList() {
- http.request({
- url: "/coupon/listByProdId",
- method: "GET",
- data: {
- prodId: this.data.prodId,
- shopId: this.data.shopId,
- },
- callBack: (res) => {
- this.setData({
- couponList: res
- })
- }
- })
- },
-
- getGroupActivity() {
- http.request({
- url: "/groupProd/info",
- method: "GET",
- data: {
- prodId: this.data.prodId,
- groupActivityId: this.data.groupActivityId,
- },
- callBack: (res) => {
- if (res.success) {
- this.setData({
- groupActivity: res.obj,
- maxNum: res.obj.maxNum,
- hasMaxNum: res.obj.hasMaxNum
- })
- this.setDefaultGroupSku();
- this.groupActivityCountdown(res.obj)
- } else {
- this.setData({
- groupActivityId: null
- });
- }
- }
- })
- },
-
- groupActivityCountdown(groupActivity) {
- let endOfGroupTime;
-
- if (groupActivity.activityStatus === 1) {
- endOfGroupTime = util.endOfStartTime(util.dateToTimestamp(groupActivity.startTime), new Date().getTime())
- } else {
- endOfGroupTime = util.endOfStartTime(new Date().getTime(), util.dateToTimestamp(groupActivity.endTime))
- }
- this.setData({
- endOfGroupTime: endOfGroupTime,
- endOfGroupTimer: setTimeout(() => this.groupActivityCountdown(groupActivity), 1000)
- })
- },
-
- getJoinGroupList() {
- http.request({
- url: "/groupProd/joinGroupList",
- method: "GET",
- data: {
- prodId: this.data.prodId,
- groupActivityId: this.data.groupActivityId,
- showSize: 3
- },
- callBack: (res) => {
- this.setData({
- joinGroupList: res
- })
- this.joinGroupListCountdown(res)
- }
- })
- },
- joinGroupListCountdown(joinGroupList) {
- joinGroupList.forEach(item => {
- item.endOfGroupTime = util.endOfStartTime(new Date().getTime(), util.dateToTimestamp(item.endTime))
- })
- this.setData({
- joinGroupList: joinGroupList,
- joinGroupListTimer: setTimeout(() => this.joinGroupListCountdown(joinGroupList), 1000)
- })
- },
-
- groupSkuProp: function (skuList) {
-
- if (skuList.length == 1 && skuList[0].properties == "") {
- this.setData({
- defaultSku: skuList[0]
- });
- this.setDefaultGroupSku();
- return;
- }
- var skuGroup = {};
- var allProperties = [];
- var propKeys = [];
- this.setData({
- selectedPropObj: {}
- });
- for (var i = 0; i < skuList.length; i++) {
- var defaultSku = this.data.defaultSku;
- var isDefault = false;
- if (!defaultSku && skuList[i].price == this.data.price) {
- defaultSku = skuList[i];
- isDefault = true;
- this.setData({
- defaultSku: defaultSku
- });
- }
- var properties = skuList[i].properties;
- allProperties.push(properties);
- var propList = properties.split(";");
- var selectedPropObj = this.data.selectedPropObj;
- for (var j = 0; j < propList.length; j++) {
- var propval = propList[j].split(":");
- var props = skuGroup[propval[0]];
-
- if (isDefault) {
- propKeys.push(propval[0]);
- selectedPropObj[propval[0]] = propval[1];
- }
- if (props == undefined) {
- props = [];
- props.push(propval[1]);
- } else {
- if (!this.array_contain(props, propval[1])) {
- props.push(propval[1]);
- }
- }
- skuGroup[propval[0]] = props;
- }
- this.setData({
- selectedPropObj: selectedPropObj,
- propKeys: propKeys
- });
- }
- this.parseSelectedObjToVals();
- this.setData({
- skuGroup: skuGroup,
- allProperties: allProperties
- });
- this.setDefaultGroupSku();
- },
-
- parseSelectedObjToVals: function () {
- var selectedPropObj = this.data.selectedPropObj;
- var selectedProperties = "";
- var selectedProp = [];
- for (var key in selectedPropObj) {
- selectedProp.push(selectedPropObj[key]);
- selectedProperties += key + ":" + selectedPropObj[key] + ";";
- }
- selectedProperties = selectedProperties.substring(0, selectedProperties.length - 1);
- this.setData({
- selectedProp: selectedProp,
- selectedProperties: selectedProperties
- });
- var findSku = false;
- for (var i = 0; i < this.data.skuList.length; i++) {
- if (this.data.skuList[i].properties == selectedProperties) {
- findSku = true;
- this.setData({
- defaultSku: this.data.skuList[i]
- });
- break;
- }
- }
- this.setData({
- findSku: findSku
- });
- this.setDefaultGroupSku();
- },
-
- toChooseItem: function (e) {
- var ok = e.currentTarget.dataset.ok;
- if (ok == 0) {
- return;
- }
- var val = e.currentTarget.dataset.val;
- var key = e.currentTarget.dataset.key;
- var selectedPropObj = this.data.selectedPropObj;
- selectedPropObj[key] = val;
- this.setData({
- selectedPropObj: selectedPropObj
- });
- this.parseSelectedObjToVals();
- },
-
- array_contain: function (array, obj) {
- for (var i = 0; i < array.length; i++) {
- if (array[i] == obj)
- return true;
- }
- return false;
- },
-
- setDefaultGroupSku() {
- if (this.data.groupActivityId) {
- var groupSkuList = this.data.groupActivity.groupSkuList;
- if (groupSkuList) {
- for (var i = 0; i < groupSkuList.length; i++) {
- if (groupSkuList[i].properties == this.data.selectedProperties) {
- this.setData({
- detaultGroupSku: groupSkuList[i]
- });
- break;
- }
- }
- }
- }
- },
-
- toSpellGroupDetail(e) {
- const groupTeamId = e.currentTarget.dataset.groupteamid
- util.checkAuthInfo(() => {
- wx.navigateTo({
- url: '/pages/spellGroupDetails/spellGroupDetails?groupTeamId=' + groupTeamId,
- })
- })
- },
-
- onReady: function () {
- this.videoContext = wx.createVideoContext('myVideo')
- },
-
- onShow: function () {
- this.getCartCount()
- if (this.data.prodType == 1) {
- this.getJoinGroupList()
- }
- },
- getCartCount: function () {
- var params = {
- url: "/p/shopCart/prodCount",
- method: "GET",
- dontTrunLogin: true,
- data: {},
- callBack: (res) => {
- if (res > 0) {
-
-
-
-
- var app = getApp();
- app.globalData.totalCartCount = res;
- } else {
-
-
-
- var app = getApp();
- app.globalData.totalCartCount = 0;
- }
- this.setData({
- totalCartNum: res
- })
- }
- };
- http.request(params);
- },
-
- preventScorll() {
- },
-
- onPullDownRefresh: function () {
- },
-
- onReachBottom: function () {
- },
-
- toHomePage: function () {
- wx.switchTab({
- url: '/pages/index/index',
- })
- },
-
- toCartPage: function () {
- wx.switchTab({
- url: '/pages/basket/basket',
- })
- },
- handleContact: function (e) {
- console.log(e.detail, '----路径')
- console.log(e.detail.query, '----参数')
-
- },
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- addToCart: function (event) {
- let skuList = this.data.skuList[0]
- if (skuList.weight > 20000) {
- wx.showToast({
- title: "商品超过20kg,太重咯~",
- icon: "none"
- })
- return;
- }
- if(this.data.totalStocks<0){
- wx.showToast({
- title: "该商品暂无库存~",
- icon: "none"
- })
- return;
- }
- if (this.data.isPlaying) {
- this._stopPlay()
- }
- if (!this.data.skuShow) {
- this.setData({
- skuShow: true
- })
- return
- }
- wx.showLoading({
- mask: true
- });
-
- util.checkAuthInfo(this.callChangeItem)
- },
- callChangeItem() {
- wx.showLoading({
- mask: true
- });
- http.request({
- url: "/p/shopCart/changeItem",
- method: "POST",
- data: {
- basketId: 0,
- count: this.data.prodNum,
- prodId: this.data.prodId,
- shopId: this.data.shopId,
- shopName: this.data.shopName,
- skuId: this.data.defaultSku.skuId,
- distributionCardNo: this.data.distributionCardNo
- },
- callBack: (res) => {
- this.setData({
- totalCartNum: this.data.totalCartNum + this.data.prodNum,
- skuShow: false,
- });
- wx.hideLoading();
- wx.showToast({
- title: "加入购物车成功",
- icon: "none"
- })
- }
- });
- },
-
- buyNow: function () {
- let skuList = this.data.skuList[0]
- if (skuList.weight > 20000) {
- wx.showToast({
- title: "商品超过20kg,太重咯~",
- icon: "none"
- })
- return;
- }
- if(this.data.totalStocks<0){
- wx.showToast({
- title: "该商品暂无库存~",
- icon: "none"
- })
- return;
- }
- if (this.data.isPlaying) {
- this._stopPlay()
- }
- if (!this.data.skuShow) {
- this.setData({
- skuShow: true
- })
- return
- }
- wx.showLoading({
- mask: true
- });
-
- util.checkAuthInfo(this._buyNowData)
- },
-
- _buyNowData() {
- wx.setStorageSync("orderItem", JSON.stringify({
- prodId: this.data.prodId,
- skuId: this.data.defaultSku.skuId,
- prodCount: this.data.prodNum,
- shopId: this.data.shopId,
- distributionCardNo: this.data.distributionCardNo
- }));
- wx.navigateTo({
- url: '/pages/submit-order/submit-order?orderEntry=1',
- })
- },
-
- onCountMinus: function () {
- var prodNum = this.data.prodNum;
- if (prodNum > 1) {
- this.setData({
- prodNum: prodNum - 1
- });
- }
- },
-
- onCountPlus: function () {
- var prodNum = this.data.prodNum;
-
- if (this.data.hasMaxNum) {
- if (prodNum < this.data.totalStocks && prodNum < this.data.maxNum) {
- this.setData({
- prodNum: prodNum + 1
- });
- } else {
- wx.showToast({
- title: '限购' + this.data.maxNum + '件',
- icon: 'none',
- })
- }
- } else {
- if (prodNum < this.data.totalStocks) {
- this.setData({
- prodNum: prodNum + 1
- });
- } else {
- wx.showToast({
- title: '库存不足!',
- icon: 'none'
- })
- }
- }
- },
-
- onShareAppMessage: function (res) {
- if (res.from === 'button') {
- var cardno = wx.getStorageSync("distCardNo");
- return {
- title: this.data.prodName,
- path: '/pages/prod/prod?prodid=' + this.data.prodId + '&cardno=' + cardno + '&type=' + this.data.shareType,
- imageUrl: this.data.pic,
- }
- } else {
- return {
- title: this.data.prodName,
- path: '/pages/prod/prod?prodid=' + this.data.prodId
- }
- }
- },
-
- showPopup: function () {
- if (this.data.loadCouponIds) {
- this.setData({
- popupShow: true
- });
- return;
- }
- http.request({
- url: "/p/myCoupon/listCouponIds",
- method: "GET",
- data: {},
- callBack: (couponIds) => {
- var couponList = this.data.couponList;
- couponList.forEach(coupon => {
- if (couponIds && couponIds.length) {
-
- var couponLimit = 0;
- couponIds.forEach(couponId => {
- if (couponId == coupon.couponId) {
- couponLimit++;
- }
- });
-
- if (couponLimit < coupon.limitNum) {
- coupon.canReceive = true;
- } else {
- coupon.canReceive = false;
- }
- } else {
- coupon.canReceive = true;
- }
- });
- this.setData({
- couponList: couponList,
- popupShow: true,
- loadCouponIds: true
- })
- }
- })
- },
- showSku: function (e) {
- if (e.currentTarget.dataset.alonebuy == 1) {
- this.setData({
- skuShow: true,
- skuShowType: 0
- });
- } else {
- if (this.data.groupActivityId) {
- this.setData({
- skuShow: true,
- skuShowType: 1
- });
- } else {
- this.setData({
- skuShow: true,
- skuShowType: 0
- });
- }
- }
- },
- showGroupSku: function () {
- if (this.data.isPlaying) {
- this._stopPlay()
- }
- this.setData({
- skuShow: true,
- skuShowType: 1
- });
- },
- showComment: function () {
- this.setData({
- commentShow: true
- });
- },
- closePopup: function () {
- this.setData({
- popupShow: false,
- skuShow: false,
- commentShow: false
- });
- },
-
- onShowShare: function (e) {
- if (this.data.isPlaying) {
- this._stopPlay()
- }
- this.setData({
- shareShow: true,
- shareType: e.currentTarget.dataset.type,
- });
- },
-
- backToTop: function () {
- wx.pageScrollTo({
- scrollTop: 0
- })
- },
-
- onPageScroll: function (e) {
- if (e.scrollTop > 80) {
- this.setData({
- showBacktop: true
- })
- } else if (e.scrollTop < 80) {
- this.setData({
- showBacktop: false
- })
- }
- },
- closeEarn: function () {
- this.setData({
- shareShow: false
- })
- },
- toDistCenterPage: function () {
- wx.navigateTo({
- url: '/pages/dis-center/dis-center',
- })
- },
-
- genWeixinCode() {
- wx.showLoading({
- mask: true
- })
- var cardNo = wx.getStorageSync("distCardNo");
- var content = JSON.stringify({
- shareProdId: this.data.prodId,
- cardNo: cardNo,
- })
- http.request({
- url: "/qrcodeTicket/miniQrCode",
- method: "GET",
- responseType: 'arraybuffer',
- data: {
- content: content,
- type: 2
- },
- callBack: (res) => {
- this.setData({
- wxCodeShow: true,
- shareShow: false,
- shareWxCode: "data:image/jpg;base64," + wx.arrayBufferToBase64(res)
- });
- wx.hideLoading();
- }
- })
- console.log('分销员id:' + cardNo)
- },
-
- closeCodePopup() {
- this.setData({
- wxCodeShow: false
- });
- },
-
- downloadImg() {
- var ths = this
- var imgSrc = this.data.shareWxCode.slice(22);
- var save = wx.getFileSystemManager();
- save.writeFile({
- filePath: wx.env.USER_DATA_PATH + '/分享商品-' + this.data.prodName + '.png',
- data: imgSrc,
- encoding: 'base64',
- success: res => {
- wx.saveImageToPhotosAlbum({
- filePath: wx.env.USER_DATA_PATH + '/分享商品-' + this.data.prodName + '.png',
- success: function (res) {
- wx.showToast({
- title: '保存成功',
- })
- ths.setData({
- wxCodeShow: false
- })
- },
- fail: function (err) {
- wx.showModal({
- title: '提示',
- content: '保存图片需要授予存储权限',
- success: modalRes => {
- if (modalRes.confirm) {
- wx.openSetting({
- success(settingdata) {
- if (settingdata.authSetting['scope.writePhotosAlbum']) {
- console.log('用户权限成功')
- } else {
- console.log('用户取消权限')
- }
- }
- })
- }
- }
- })
- }
- })
-
- },
- fail: err => {
-
- }
- })
- },
-
- onGotUserInfo: function (e) {
- if (e.detail.errMsg != "getUserInfo:fail auth deny") {
- this.setData({
- isAuthInfo: true
- });
- http.updateUserInfo();
- }
- },
-
- groupConfirmOrder: function (e) {
- if (!this.data.findSku) {
- return;
- }
- wx.showLoading({
- mask: true
- });
- this.setData({
- teamId: e.currentTarget.dataset.teamid
- })
-
- util.checkAuthInfo(this._groupConfirmParams)
- },
-
- _groupConfirmParams() {
- wx.setStorageSync("groupOrderItem", JSON.stringify({
- groupSkuId: this.data.detaultGroupSku.groupSkuId,
- prodCount: this.data.prodNum,
- groupTeamId: this.data.teamId
- }));
- wx.navigateTo({
- url: '/pages/groupConfirmOrder/groupConfirmOrder',
- })
- },
-
- toShopPage: function () {
- wx.navigateTo({
- url: '/pages/shopPage/shopPage?shopId=' + this.data.shopId,
- })
- },
-
- getPordDiscountList() {
- http.request({
- url: "/marking/discount/getDiscountByProdId",
- method: "GET",
- data: {
- prodId: this.data.prodId
- },
- callBack: res => {
- this.setData({
- prodDiscountList: res
- })
- }
- })
- },
-
- clickDiscount: function () {
- var showDiscountPopup = !this.data.showDiscountPopup
- this.setData({
- showDiscountPopup
- })
- },
-
- onHide: function () {
- this.setData({
- isCollection: false,
- skuShow: false,
- })
- clearTimeout(this.data.joinGroupListTimer)
- },
-
- getVideoInfo() {
- wx.showLoading()
- wx.request({
- url: this.data.video + '?avinfo',
- success: res => {
- wx.hideLoading()
- let time = Number(res.data.format.duration).toFixed(0)
- this.setData({
- videoDuration: time < 60 ? '00′' + time + '″' : ((parseInt(time / 60) < 10 ? '0' + parseInt(time / 60) : parseInt(time / 60)) + '′' + (time % 60 < 10 ? '0' + time % 60 : time % 60) + '″')
- })
- }
- })
- },
-
- videoOper() {
- if (this.data.isPlaying) {
- this._stopPlay()
- } else {
- this._startPlay()
- }
- },
-
- playEnd() {
- this._stopPlay()
- },
- _startPlay() {
- this.setData({
- isPlaying: true,
- })
- this.videoContext.play()
- this.videoContext.seek(0)
- },
- _stopPlay() {
- this.setData({
- isPlaying: false
- })
- this.videoContext.stop()
- this.videoContext.seek(0)
- },
- })
|