Commit 8db28035 by 谢中龙

优化功能

parent 209423dc
......@@ -16,11 +16,20 @@
<template name="water-list">
<navigator hover-class="none" url="/pages/productDetail/productDetail?id={{productId}}">
<view class="item">
<!-- 图片主图时 -->
<image class="item-img"
src="{{indexUrl}}"
mode="widthFix" lazy-load
wx:if="{{!utils.isVideo(indexUrl)}}"
binderror="imgLoadError"
data-index="{{index}}"></image>
<video id="myVideo"
class="item-img video-cover"
src="{{indexUrl}}"
muted
wx:if="{{utils.isVideo(indexUrl)}}"></video>
<view class="item-title-box">
<view class="item-title">{{productName}}</view>
</view>
......
......@@ -31,6 +31,9 @@
border-top-left-radius: 10rpx;
border-top-right-radius: 10rpx;
}
.video-cover{
max-height: 188px;
}
.item-title{
font-size: 25rpx;
text-overflow: ellipsis;
......
......@@ -4,7 +4,16 @@
<navigator hover-class="none" url="/pages/productDetail/productDetail?id={{item.productId}}">
<view class="hot-item border_box" >
<view class="hot-img-box">
<image class="hot-img" src="{{item.indexUrl}}" mode="widthFix" lazy-load />
<image class="hot-img"
src="{{item.indexUrl}}"
mode="aspectFit" lazy-load
wx:if="{{!utils.isVideo(item.indexUrl)}}"/>
<video id="myVideo"
class="hot-img"
src="{{item.indexUrl}}"
muted
wx:if="{{utils.isVideo(item.indexUrl)}}"></video>
</view>
<view class="hot-item-desc border_box">
<view class="item-name">{{item.productName}}</view>
......
<!--component/scrollDel/scrollDel.wxml-->
<!--<scroll-view scroll-y="{{isScroll}}" style='height:{{windowHeight}}px'>-->
<wxs src="../../wxs/utils.wxs" module="utils" />
<scroll-view scroll-y="{{isScroll}}">
<block class="cart-item" wx:key="item" wx:for="{{cartList}}">
<view data-index='{{index}}'
......@@ -16,7 +17,17 @@
<!-- productStatus 0未发布1下架2上架3删除 -->
<view class="pro-info" bindtap="bindTapItem" data-id="{{item.productId}}"
style='border-bottom:{{index == (cartList.length -1) ? "none" : "1rpx solid #eeeeee" }};opacity:{{(item.productStatus == 1 || item.productStatus == 1 || item.productStatus == 3) ? 0.2 : 1}};'>
<image class="pro-img" src="{{item.skuImgUrl}}" mode="widthFix"></image>
<image class="pro-img" src="{{item.skuImgUrl}}"
wx:if="{{!utils.isVideo(item.skuImgUrl)}}"
mode="widthFix"></image>
<video id="myVideo"
class="hot-img"
src="{{item.skuImgUrl}}"
muted
wx:if="{{utils.isVideo(item.skuImgUrl)}}"></video>
<view class="pro-right-info">
<view class="pro-name">{{item.productName}}</view>
<view class="pro-sku">{{item.skuSpec}}</view>
......
......@@ -6,11 +6,20 @@
<image
class="popup-close"
mode="widthFix"
src="/images/close.png"
src="/assets/imgs/close.png"
bindtap="hidePopup"
/>
<view class="top-info clearfix">
<image mode="widthFix" src="{{picUrl && picUrl != 'undefined' ? picUrl : indexImg}}" />
<image mode="widthFix"
wx:if="{{!utils.isVideo(picUrl && picUrl != 'undefined' ? picUrl : indexImg)}}"
src="{{picUrl && picUrl != 'undefined' ? picUrl : indexImg}}" />
<video
style="width:210rpx;height:210rpx;"
src="{{picUrl && picUrl != 'undefined' ? picUrl : indexImg}}"
muted
wx:if="{{utils.isVideo(picUrl && picUrl != 'undefined' ? picUrl : indexImg)}}"></video>
<view class="top-text">
<!-- <view class="price-text" wx:if="{{exchangePrice <= 0}}">¥{{price / 100}}</view> -->
<view class="price-text">¥{{utils.numberFormat(salePrice /100)}}</view>
......
......@@ -13,23 +13,7 @@
/>
</view>
<!-- 失效宝贝 -->
<view class="overdue-pro" wx:if="{{outGoods.length}}">
<view class="clear-btn">清除失效商品</view>
<view class="overdue-list clearflex">
<view class="overdue-status">失效</view>
<view class="pro-info">
<image class="pro-img" src="https://img3.bigaka.com/prd/3001/202003/20200331/3001a1a3d3df-d083-426c-b4cd-388886e44360.png" mode="widthFix" />
<view class="pro-right-info">
<view class="pro-name overdue-name">商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称商品名称</view>
<view class="pro-sku">规格</view>
<view class="pro-price">
<view class="price overdue-price">¥256</view>
</view>
</view>
</view>
</view>
</view>
<!-- 空状态时 -->
<view class="empty" wx-if="{{cartList !== null && cartList.length == 0}}">
<view class="empty-img">
......
......@@ -248,6 +248,22 @@ wxService.page({
})
},
//获取数组中第一个图片格式的url
isVideoUrl(url){
if(url){
let lastIndexOfPoint = url.lastIndexOf('.');
let extd = url.substring(lastIndexOfPoint).toUpperCase();
if(extd != '.MP4' && extd != '.MP3' && extd != ".MOV"){
return false;
}
else{
return true;
}
}
return false;
},
//获取商品详情
getProductInfoById(productId){
return wxService.get(`/sale/product/buyer/findByProductId?productId=${productId}`);
......@@ -307,20 +323,30 @@ wxService.page({
if (res) {
const { result, data } = res.data
if (result == 0) {
wx.hideLoading()
wx.hideLoading();
let list = data.content ? data.content : [];
list.forEach(item => {
item.productImgUrl = !this.isVideoUrl(item.productImgUrl) ? item.productImgUrl : defaultProImg;
item.productImgUrl = item.productImgUrl ? item.productImgUrl :defaultProImg;
});
if(this.data.pageNo == 1){
this.data.extendProList = list;
}
else{
this.data.extendProList = this.data.extendProList.concat(list);
}
this.setData({
extendProList: this.data.pageNo == 1 ? [...data.content] : [...this.data.extendProList, ...data.content],
extendProList: this.data.extendProList,
totalPages: data.totalPages
}, () => {
// this.setData({
// no_data: this.data.extendProList.length ? true : false
// })
})
});
}
}
})
},
// 获取我的推广订单列表
getMyExtendOrderList(pageNum, pageSize){
wx.showLoading({
......
......@@ -51,9 +51,7 @@
<view class="buy-product-content">
<view class="buy-list" wx:if="{{extendProList.length}}" wx:for="{{extendProList}}" wx:key="{{index}}">
<view class="prod-img">
<image
src="{{item.productImgUrl || 'https://img3.bigaka.com/prd/3001/202003/20200331/30019aa78220-546f-41e0-8075-c2feb69e10b8.jpg'}}"
mode='aspectFit'/>
<image src="{{item.productImgUrl}}" mode='aspectFit'/>
</view>
<view class="prod-info">
<view class="prod-name">{{item.productName}}</view>
......
......@@ -117,7 +117,7 @@ wxService.page({
let content = {
title: this.data.productInfo.productName,
id: this.data.productInfo.productId,
url: this.data.productInfo.indexUrl
url: this.getFirstImgUrl(this.data.productInfo.listUrls)
}
let tentacleInfo = {
content: JSON.stringify(content),
......@@ -140,13 +140,29 @@ wxService.page({
this.setData({
showCardModal: true,
cardTitle: this.data.productInfo.productName,
cardUrl: this.data.productInfo.indexUrl,
cardUrl: this.getFirstImgUrl(this.data.productInfo.listUrls),
pagePath: path,
scene: scene
});
}
})
},
//获取第一个不是视频的主图
//获取数组中第一个图片格式的url
getFirstImgUrl(urls){
let retUrl = '';
for(let i = 0 ; i < urls.length ; i ++){
let url = urls[i];
let lastIndexOfPoint = url.lastIndexOf('.');
let extd = url.substring(lastIndexOfPoint).toUpperCase();
if(extd != '.MP4' && extd != '.MP3' && extd != ".MOV"){
retUrl = url;
break;
}
}
return retUrl;
},
/**
* 生命周期函数--监听页面显示
*/
......@@ -323,8 +339,8 @@ wxService.page({
let parmas = {
trolleySku2Buy: JSON.stringify(trolleySku2Buy)
}
const { fromZc } = this.data
console.log('fromZc', fromZc)
const { fromZc } = this.data;
//判断是否从种草商品过来购买
if (fromZc) {
wxService.updateLocalTentacleInfo();
......@@ -376,7 +392,7 @@ wxService.page({
return {
title: this.data.productInfo.productName,
path: path,
imageUrl: this.data.productInfo.indexUrl
imageUrl: this.getFirstImgUrl(this.data.productInfo.listUrls)
}
} else {
//修改为参数memberId
......@@ -393,7 +409,7 @@ wxService.page({
return {
title: this.data.productInfo.productName,
path: path,
imageUrl: this.data.productInfo.indexUrl
imageUrl: this.getFirstImgUrl(this.data.productInfo.listUrls)
}
}
......
......@@ -14,7 +14,16 @@
<swiper autoplay="true" style="height: 750rpx;line-height: 100rpx;" bindchange="swiperChange">
<block wx:for="{{productInfo.listUrls}}" wx:key="index">
<swiper-item>
<image class="swiper-image" mode="widthFix" src="{{item}}" lazy-load/>
<image class="swiper-image"
mode="widthFix" src="{{item}}"
wx:if="{{!utils.isVideo(item)}}"
lazy-load/>
<video id="myVideo{{index}}"
class="swiper-image video-cover"
src="{{item}}"
muted
wx:if="{{utils.isVideo(item)}}"></video>
</swiper-item>
</block>
</swiper>
......
......@@ -12,6 +12,12 @@ page{
.swiper-image{
width: 100%;
}
.video-cover{
width: 100%;
height: 100%;
}
.product-price {
display: flex;
justify-content: space-between;
......
......@@ -132,7 +132,8 @@ wxService.page({
this.data.goods.goodsList = list;
list.forEach(item => {
item.price = parseFloat(item.minSalePrice/10/10).toFixed(2);
item.productImgUrl = item.indexUrl;
item.productImgUrl = !this.isVideoUrl(item.indexUrl) ? item.indexUrl :defaultGoodsImg;
item.productImgUrl = item.productImgUrl ? item.productImgUrl :defaultGoodsImg;
});
this.setData({
......@@ -141,6 +142,21 @@ wxService.page({
}
})
},
//获取数组中第一个图片格式的url
isVideoUrl(url){
if(url){
let lastIndexOfPoint = url.lastIndexOf('.');
let extd = url.substring(lastIndexOfPoint).toUpperCase();
if(extd != '.MP4' && extd != '.MP3' && extd != ".MOV"){
return false;
}
else{
return true;
}
}
return false;
},
//跳转到商品详情
onTapToGoodsDetail(e){
let item = e.currentTarget.dataset.item;
......
// shoppingGuid/page/pages/moreProducts/moreProducts.js
const wxService = require('../../../../utils/wxService')
import { Integer } from '../../../../utils/integerDigitalConvertion'
let defaultUrl = 'https://img3.bigaka.com/prd/3001/202003/20200331/30019aa78220-546f-41e0-8075-c2feb69e10b8.jpg';
const app = getApp();
wxService.page({
......@@ -126,7 +127,8 @@ wxService.page({
this.data.goods.goodsList = list;
list.forEach(item => {
item.price = parseFloat(item.minSalePrice/10/10).toFixed(2);
item.productImgUrl = item.indexUrl;
item.productImgUrl = !this.isVideoUrl(item.indexUrl) ? item.indexUrl : defaultUrl;
item.productImgUrl = item.productImgUrl ? item.productImgUrl : defaultUrl;
});
this.setData({
......@@ -136,6 +138,21 @@ wxService.page({
})
},
//获取数组中第一个图片格式的url
isVideoUrl(url){
if(url){
let lastIndexOfPoint = url.lastIndexOf('.');
let extd = url.substring(lastIndexOfPoint).toUpperCase();
if(extd != '.MP4' && extd != '.MP3' && extd != ".MOV"){
return false;
}
else{
return true;
}
}
return false;
},
//跳转到商品详情
onTapToGoodsDetail(e) {
let item = e.currentTarget.dataset.item;
......
......@@ -54,6 +54,7 @@ wxService.page({
list.forEach(item => {
item.checked = false;
item.minSalePriceText = parseFloat(item.minSalePrice/10/10).toFixed(2);
item.indexUrl = !this.isVideoUrl(item.indexUrl) ? item.indexUrl : 'https://img3.bigaka.com/prd/3001/202003/20200331/30019aa78220-546f-41e0-8075-c2feb69e10b8.jpg'
});
this.data.productList = this.data.productList.concat(list);
......@@ -72,6 +73,21 @@ wxService.page({
}
});
},
//获取数组中第一个图片格式的url
isVideoUrl(url){
if(url){
let lastIndexOfPoint = url.lastIndexOf('.');
let extd = url.substring(lastIndexOfPoint).toUpperCase();
if(extd != '.MP4' && extd != '.MP3' && extd != ".MOV"){
return false;
}
else{
return true;
}
}
return false;
},
//处理选中
handlerChecked(){
let checkedProduct = wx.getStorageSync('guiderReleaseProducts') ? wx.getStorageSync('guiderReleaseProducts') : [];
......
// shoppingGuid/page/pages/taskNotice/taskNotice.js
const wxService = require('../../../../utils/wxService')
import { Integer } from '../../../../utils/integerDigitalConvertion'
let defaultImg = 'https://img3.bigaka.com/prd/3001/202003/20200331/30019aa78220-546f-41e0-8075-c2feb69e10b8.jpg';
const app = getApp();
wxService.page({
/**
......@@ -85,7 +86,8 @@ wxService.page({
this.data.goods.goodsList = list;
list.forEach(item => {
item.price = parseFloat(item.minSalePrice/10/10).toFixed(2);
item.productImgUrl = item.indexUrl;
item.productImgUrl = !this.isVideoUrl(item.indexUrl) ? item.indexUrl : defaultImg ;
item.productImgUrl = item.productImgUrl ? item.productImgUrl : defaultImg ;
});
this.setData({
......@@ -95,6 +97,22 @@ wxService.page({
})
},
//获取数组中第一个图片格式的url
isVideoUrl(url){
if(url){
let lastIndexOfPoint = url.lastIndexOf('.');
let extd = url.substring(lastIndexOfPoint).toUpperCase();
if(extd != '.MP4' && extd != '.MP3' && extd != ".MOV"){
return false;
}
else{
return true;
}
}
return false;
},
//定向发送
//定向转发商品给用户 分享功能
onTapToShare(e) {
......
......@@ -2,6 +2,7 @@
var app = getApp()
const wxService = require('../../../../utils/wxService')
import { Integer } from '../../../../utils/integerDigitalConvertion'
let defaultImg = 'https://img3.bigaka.com/prd/3001/202003/20200331/30019aa78220-546f-41e0-8075-c2feb69e10b8.jpg';
wxService.page({
......@@ -145,7 +146,7 @@ wxService.page({
wx.hideLoading()
this.data.proData = this.data.pageNo == 1 ? [...data.content] : [...this.data.proData, ...data.content];
this.data.proData.forEach(item => {
item.indexUrl = item.indexUrl ? item.indexUrl : 'https://img3.bigaka.com/prd/3001/202003/20200331/30019aa78220-546f-41e0-8075-c2feb69e10b8.jpg';
item.indexUrl = item.indexUrl ? item.indexUrl : defaultImg;
});
this.setData({
proData: this.data.proData,
......@@ -165,6 +166,24 @@ wxService.page({
wx.hideLoading()
})
},
//找到第一个是图片的主图
//获取数组中第一个图片格式的url
getFirstImgUrl(urls){
let retUrl = '';
for(let i = 0 ; i < urls.length ; i ++){
let url = urls[i];
let lastIndexOfPoint = url.lastIndexOf('.');
let extd = url.substring(lastIndexOfPoint).toUpperCase();
if(extd != '.MP4' && extd != '.MP3' && extd != ".MOV"){
retUrl = url;
break;
}
}
return retUrl;
},
//获取商品列表 通过tagid
getProductListByTagId(refresh){
wx.showLoading({
......
......@@ -53,6 +53,21 @@ function hanlerLinkNeedAuth(link){
return flag
}
//判断是否是视频格式
function isVideo(url){
if(url){
var lastIndexOfPoint = url.lastIndexOf('.');
var extd = url.substring(lastIndexOfPoint).toUpperCase();
if(extd != '.MP4' && extd != '.MP3' && extd != ".MOV"){
return false;
}
return true;
}
return false;
}
module.exports = {
toPercent:toPercent,
......@@ -61,5 +76,6 @@ module.exports = {
numberFormat: numberFormat,
date: date,
handerNickName: handerNickName,
hanlerLinkNeedAuth: hanlerLinkNeedAuth
hanlerLinkNeedAuth: hanlerLinkNeedAuth,
isVideo : isVideo,
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment