Commit 63c8e5ba by 施宇

1111

parent 188b38a1
// components/priceItem/priceItem.js
import {
judgeToken
} from '../../utils/util.js';
Component({
/**
* 组件的属性列表
......@@ -30,14 +33,13 @@ Component({
*/
methods: {
emitevent: function (e) {
let token = wx.getStorageSync('access_token');
let inquiryItemsId = e.currentTarget.dataset.inquiryitemsid;
let goodId = e.currentTarget.dataset.goodid;
let offerId = e.currentTarget.dataset.offerid;
let xb = e.currentTarget.dataset.xb;
let type = e.currentTarget.dataset.type;//1代表询价 2代表报价 3代表商品
let priceType = e.currentTarget.dataset.pricetype;
if (token) {
if (judgeToken(true)) {
if (priceType == 1) {
if (type == 1) {
wx.navigateTo({
......@@ -70,12 +72,6 @@ Component({
url: "/pages/detail/good/index?goodId=" + goodId + '&type=1'
})
}
} else {
wx.showToast({
title: '请先登入',
icon: 'none',
duration: 2000
});
}
},
previewImage: function (e) {
......
// pages/detail/good/index.js
import { getData, changeTime } from '../../../utils/util.js';
import { getData, changeTime } from '../../../utils/util.js';
import { apis } from '../../../utils/api.js';
Page({
......@@ -8,9 +8,9 @@ Page({
*/
data: {
info: null,
editOrShow:-1,//1编辑 2在线沟通
goodId:"",
type:"",
editOrShow: -1,//1编辑 2在线沟通
goodId: "",
type: "",
},
/**
......@@ -21,7 +21,7 @@ Page({
goodId: options.goodId || '',
type: options.type || ''
})
},
getData: function () {
let me = this;
......@@ -31,11 +31,11 @@ Page({
let type = me.data.type;
if (type == 1) {
url = apis.goodsInfo;
} else if (type == 2) {
} else if (type == 2 || type == 3) {
url = apis.goodsSearch;
} else {
return;
}
getData(url, 'get', {
"goods_id/eq": goodId,
......@@ -49,11 +49,11 @@ Page({
} else {
let userId = wx.getStorageSync('user_id');
let targetId = res.goods_list[goodId]['user_id'];
if(type == 1){
if (type == 1) {
me.setData({
editOrShow: 1
})
}else if(type == 2){
} else if (type == 2) {
if (userId == targetId) {
me.setData({
editOrShow: 1
......@@ -77,12 +77,12 @@ Page({
}
}, true)
},
editGood:function(){
editGood: function () {
wx.navigateTo({
url: "/pages/form/good/index?goodId="+this.data.goodId,
url: "/pages/form/good/index?goodId=" + this.data.goodId,
})
},
sendTemplate:function(){
sendTemplate: function () {
let data = this.data.info;
let my = wx.getStorageSync("myUsername");
let companyName = wx.getStorageSync("company_name");
......
......@@ -49,7 +49,7 @@ Page({
total: res.total,
});
} else {
if ((me.data.p == 1) && (res.errcode == (105001 || 105015))) {
if (me.data.p == 1) {
me.setData({
priceList: []
})
......
......@@ -16,6 +16,7 @@ Page({
key: "",
confirmKey: "",
isShowBottom: false,
token:''
},
......@@ -27,7 +28,8 @@ Page({
let key = options.key;
this.setData({
key: key,
confirmKey: key
confirmKey: key,
token: wx.getStorageSync('access_token') || ''
});
this.storageKey(key)
this.getData();
......
<!--pages/searchresult/index.wxml-->
<view class="searchresult-view">
<view class="searchresult-view {{token?'searchresult-padding-bottom':''}}">
<view class="search-com">
<text class="icon iconfont iconiconxiantiaoshouji8"></text>
<input placeholder='请输入芯片型号' placeholder-class="placeholderClass" value="{{key}}" bindinput="bindKeyInput" bindconfirm="bindKeyConfirm"></input>
......@@ -19,13 +19,13 @@
<image src="/res/images/imgs/nodata.png" class="img"></image>
<view class="h3 bold">未搜索到相关信息</view>
<view class="p">
<text wx:if="{{tabIndex == 2}}">您还可以发布询价。</text>
<text wx:if="{{tabIndex == 1}}">您还可以新增商品。</text>
<text wx:if="{{tabIndex == 2&&token}}">您还可以发布询价。</text>
<text wx:if="{{tabIndex == 1&&token}}">您还可以新增商品。</text>
</view>
<view class="nodata_fb btn-com btn-com-b" bindtap="toXj" wx:if="{{tabIndex == 2}}">
<view class="nodata_fb btn-com btn-com-b" bindtap="toXj" wx:if="{{tabIndex == 2&&token}}">
<text>快速发布询价</text>
</view>
<view class="nodata_fb btn-com btn-com-b" bindtap="toSp" wx:if="{{tabIndex == 1}}">
<view class="nodata_fb btn-com btn-com-b" bindtap="toSp" wx:if="{{tabIndex == 1&&token}}">
<text class="icon iconfont iconiconxiantiaoshouji15"></text>
<text>新增商品</text>
</view>
......@@ -37,18 +37,18 @@
<text class="line"></text>
</view>
</view>
<view class="fast_fb_view" wx:if="{{priceList&&priceList.length!==0&&tabIndex == 2}}">
<view class="fast_fb_view" wx:if="{{priceList&&priceList.length!==0&&tabIndex == 2&&token}}">
<view class="fast_fb btn-com btn-com-b" bindtap="toXj">
<text>快速发布询价</text>
</view>
</view>
<view class="fast_fb_view" wx:if="{{priceList&&priceList.length!==0&&tabIndex == 1}}">
<view class="fast_fb_view" wx:if="{{priceList&&priceList.length!==0&&tabIndex == 1&&token}}">
<view class="fast_fb btn-com btn-com-b" bindtap="toSp">
<text class="icon iconfont iconiconxiantiaoshouji15"></text>
<text>新增商品</text>
</view>
</view>
<view class="concat_custom" wx:if="{{priceList&&priceList.length==0&&tabIndex == 2}}">
<view class="concat_custom" wx:if="{{priceList&&priceList.length==0&&tabIndex == 2&&token}}">
<text class="icon iconfont iconiconxiantiaoshouji11" bindtap="sendCustomer"></text>
<text bindtap="sendCustomer">联系客服帮您找</text>
</view>
......
......@@ -4,9 +4,11 @@
min-height: 100%;
position: relative;
box-sizing: border-box;
padding:174rpx 0 158rpx;
padding-top:174rpx;
}
.searchresult-padding-bottom{
padding-bottom:158rpx;
}
.searchresult-view .search-com, .searchresult-view .switch-tab-com {
position: fixed;
top: 0;
......
......@@ -2,6 +2,5 @@
"usingComponents": {
"priceItem": "/components/priceItem/priceItem"
},
"navigationBarTitleText": "商品管理",
"enablePullDownRefresh":true
"navigationBarTitleText": "商品管理"
}
\ No newline at end of file
......@@ -50,7 +50,7 @@ Page({
total:res.total,
});
}else{
if ((me.data.p == 1) && (res.errcode == (105001 || 105015))){
if (me.data.p == 1){
me.setData({
priceList: []
})
......
......@@ -48,7 +48,7 @@
"list": []
},
"miniprogram": {
"current": 25,
"current": 26,
"list": [
{
"id": -1,
......@@ -229,6 +229,14 @@
"id": -1,
"name": "pages/tab/home/home",
"pathName": "pages/tab/home/home",
"query": "",
"scene": null
},
{
"id": 26,
"name": "pages/detail/good/index",
"pathName": "pages/detail/good/index",
"query": "goodId=156274103196309&type=3",
"scene": null
}
]
......
const auth_url = 'http://authapi.icsales.cc';
const so_url = 'http://soapi.icsales.cc';
const offer_url = "http://offerapi.icsales.cc";
const user_url = 'http://userapi.icsales.cc';
const goods_url = 'http://goodsapi.icsales.cc';
const home_url = 'http://home.icsales.cc';
const auth_url = 'https://authapi.icsales.com';
const so_url = 'https://soapi.icsales.com';
const offer_url = "https://offerapi.icsales.com";
const user_url = 'https://userapi.icsales.com';
const goods_url = 'https://goodsapi.icsales.com';
const home_url = 'https://home.icsales.com';
// const auth_url = 'http://authapi.icsales.cc';
// const so_url = 'http://soapi.icsales.cc';
// const offer_url = "http://offerapi.icsales.cc";
// const user_url = 'http://userapi.icsales.cc';
// const goods_url = 'http://goodsapi.icsales.cc';
// const home_url = 'http://home.icsales.cc';
const apis = {
/**
......
......@@ -86,48 +86,46 @@ const getData = (url, type, param, callBack, loading, isheader, istoken) => {
};
//上传文件
const uploadFile = (url, paths, callBack) => {
const uploadFile = (url, path, callBack) => {
wx.showLoading({
title: '上传中',
mask: true
})
for (var i = 0; i < paths.length; i++) {
wx.uploadFile({
url: url,
filePath: paths[i],
name: 'upload',
formData: {
token: wx.getStorageSync('access_token'),
source: 2
},
header: {
"Content-Type": "multipart/form-data"
},
success: (res) => {
var data = JSON.parse(res.data);
if (data.errcode == 103200) {
callBack(data.data[0])
} else {
wx.showToast({
title: '上传失败',
icon: 'none',
duration: 2000
});
}
},
fail: (e) => {
console.log(e)
});
wx.uploadFile({
url: url,
filePath: path,
name: 'upload',
formData: {
token: wx.getStorageSync('access_token'),
source: 2
},
success: (res) => {
console.log(res)
var data = JSON.parse(res.data);
console.log(data)
if (data.errcode == 103200) {
callBack(data.data[0])
} else {
wx.showToast({
title: '上传失败',
icon: 'none',
duration: 2000
});
},
complete: () => {
wx.hideLoading();
}
})
}
},
fail: (e) => {
console.log(e)
wx.showToast({
title: '上传失败',
icon: 'none',
duration: 2000
});
},
complete: () => {
wx.hideLoading();
}
})
};
const chooseImg = (url, num, callback) => {
......@@ -136,7 +134,7 @@ const chooseImg = (url, num, callback) => {
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: (res) => {
uploadFile(url, res.tempFilePaths, (rtn) => {
uploadFile(url, res.tempFilePaths[0], (rtn) => {
callback(rtn)
})
}
......@@ -217,20 +215,20 @@ const sha1 = (s) => {
s[l - 1] = data.length << 3;
var w = [],
f = [
function () {
function() {
return m[1] & m[2] | ~m[1] & m[3];
},
function () {
function() {
return m[1] ^ m[2] ^ m[3];
},
function () {
function() {
return m[1] & m[2] | m[1] & m[3] | m[2] & m[3];
},
function () {
function() {
return m[1] ^ m[2] ^ m[3];
}
],
rol = function (n, c) {
rol = function(n, c) {
return n << c | n >>> (32 - c);
},
k = [1518500249, 1859775393, -1894007588, -899497514],
......@@ -247,7 +245,7 @@ const sha1 = (s) => {
t = new DataView(new Uint32Array(m).buffer);
for (var i = 0; i < 5; i++) m[i] = t.getUint32(i << 2);
var hex = Array.prototype.map.call(new Uint8Array(new Uint32Array(m).buffer), function (e) {
var hex = Array.prototype.map.call(new Uint8Array(new Uint32Array(m).buffer), function(e) {
return (e < 16 ? "0" : "") + e.toString(16);
}).join("");
return hex;
......@@ -273,9 +271,16 @@ const judgeToken = (boolen) => {
return true
} else {
if (boolen) {
wx.redirectTo({
url: '/pages/person/login/index'
})
if (wx.getStorageSync('auth')) {
wx.redirectTo({
url: '/pages/person/login/index'
})
} else {
wx.redirectTo({
url: '/pages/person/auth/index'
})
}
}
return false;
}
......@@ -306,7 +311,7 @@ const interval = (usedTime) => {
}
}
}
const matchReg = (str)=>{
const matchReg = (str) => {
let reg = /<\/?.+?\/?>/g;
let newStr = str.replace(reg, '');
return newStr
......
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 sign in to comment