Browse Source

对接登录、注册、商品分类和部分商品分类详情

master
ltlzx 3 years ago
parent
commit
c22ec6c5ef
  1. 20
      api/index.js
  2. 66
      api/request.js
  3. 6
      common/common.scss
  4. 4
      config.js
  5. 35
      package-lock.json
  6. 6
      package.json
  7. 36
      pages/category/index.vue
  8. 13
      pages/category/productList.vue
  9. 137
      pages/login/index.vue
  10. 14
      pages/login/verifyEmail.vue
  11. 6191
      utils/crypto-js.js
  12. 40
      utils/des.js

20
api/index.js

@ -0,0 +1,20 @@
import httpRequest from './request';
//默认请求地址
export const defaultRequest =query=>{
return httpRequest({
url:'mapi/api_v2011.php?appcode=DOPE+',
method:'post',
data:query,
errMsg:true
})
}
//默认请求地址 不显示错误信息
export const defaultRequest1 =query=>{
return httpRequest({
url:'mapi/api_v2011.php?appcode=DOPE+',
method:'post',
data:query,
errMsg:false
})
}

66
api/request.js

@ -1,31 +1,64 @@
import config from '../config.js'
const json_data={
appcode:'SHISE' ,//应用编码
appchannel:'FXXXXHUAWEI' ,//应用发布渠道
appver: '1.0.0',//应用版本
appname:'cnic_buyer' ,//应用名称
manufacturer:'HUAWEI' ,//设备生产商
phonebrand:'HORNOR' ,//设备品牌
phonetype:'X30' ,//设备型号
phoneos:'ANDROID'// 设备系统
}
import { encryptDes, decryptDes ,encrypt_by_des } from '@/utils/des.js'
import Base64 from 'base-64';
import cryptoJS from "crypto-js"
const httpRequest = (params) => {
uni.showLoading({
title: "努力加载中..."
});
const json_data={
appcode:'DOPE+' ,//应用编码
appchannel:'FXXXXHUAWEI' ,//应用发布渠道
appver: '1.0.0',//应用版本
appname:'cnic_buyer' ,//应用名称
manufacturer:'HUAWEI' ,//设备生产商
phonebrand:'HORNOR' ,//设备品牌
phonetype:'X30' ,//设备型号
phoneos:'ANDROID'// 设备系统
}
let data=Object.assign(json_data,params.data)
console.info(data)
data=encryption(data)
//进行加密
// console.info(encryptDes(JSON.stringify(data),'6780f04cf2e211ec86a8005056c00008'))
// console.info(encrypt_by_des(JSON.stringify(data),'6780f04cf2e211ec86a8005056c00008'))
// data=Base64.encode(encryptDes(JSON.stringify(data),'6780f04cf2e211ec86a8005056c00008'));
data=encryptDes(JSON.stringify(data),'6780f04cf2e211ec86a8005056c00008');
// console.info(data)
// 解密
// let data2 =JSON.parse(decodeURIComponent (decryptDes(Base64.decode(data),'6780f04cf2e211ec86a8005056c00008'))) ;
// console.info(data2)
let data1={data:data}
let httpOptions = {
url: config.apiUri + params.url,
data: params.data,
data:data1,
method: params.method,
header: {'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'}
header: {
'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8',
'cookies':uni.getStorageSync('cookies') || ""
}
};
return new Promise((resolve, reject) => {
uni.request({
...httpOptions,
success: res => {
uni.hideLoading();
resolve(res);
// 进行解密
res.data=JSON.parse(decryptDes(res.data,'6780f04cf2e211ec86a8005056c00008'))
// res.data=Base64.decode(decryptDes(res.data,'6780f04cf2e211ec86a8005056c00008'));
// console.info(res.data)
if(res.data.error!=0 && params.errMsg){
uni.showToast({
title: res.data.message,
icon:'none',
duration: 2000
});
}
resolve(res.data);
},
fail: err => {
uni.hideLoading();
@ -35,5 +68,12 @@ const httpRequest = (params) => {
})
}
const encryption=(data)=>{
for(let key in data){
let item= data[key]
data[key]=encodeURIComponent(item)
}
return data
}
export default httpRequest;

6
common/common.scss

@ -513,10 +513,16 @@
line-height: 88rpx;
background-color: #000000;
color: white;
// background-color: #e7e7e7;
// color: #666666;
border-radius: 6.67rpx;
margin-bottom: 52rpx;
font-weight: bold;
}
.login_submit1{
background-color: #000000;
color: white;
}
.agreement{
display: flex;
// align-items: center;

4
config.js

@ -1,5 +1,5 @@
var weburl='https://en.meixx.com/mapi/api_v2011.php';
var weburl='en.meixx.com';
export default {
apiUri: 'http://'+weburl+'/api/',
apiUri: 'https://'+weburl+'/',
imgUri: 'http://'+weburl+'/',
}

35
package-lock.json

@ -0,0 +1,35 @@
{
"name": "cnic_buyer",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"dependencies": {
"base-64": "^1.0.0",
"crypto-js": "^4.1.1"
}
},
"node_modules/base-64": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/base-64/-/base-64-1.0.0.tgz",
"integrity": "sha512-kwDPIFCGx0NZHog36dj+tHiwP4QMzsZ3AgMViUBKI0+V5n4U0ufTCUMhnQ04diaRI8EX/QcPfql7zlhZ7j4zgg=="
},
"node_modules/crypto-js": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.1.1.tgz",
"integrity": "sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw=="
}
},
"dependencies": {
"base-64": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/base-64/-/base-64-1.0.0.tgz",
"integrity": "sha512-kwDPIFCGx0NZHog36dj+tHiwP4QMzsZ3AgMViUBKI0+V5n4U0ufTCUMhnQ04diaRI8EX/QcPfql7zlhZ7j4zgg=="
},
"crypto-js": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.1.1.tgz",
"integrity": "sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw=="
}
}
}

6
package.json

@ -0,0 +1,6 @@
{
"dependencies": {
"base-64": "^1.0.0",
"crypto-js": "^4.1.1"
}
}

36
pages/category/index.vue

@ -21,27 +21,27 @@
</view>
<view class="category">
<view class="category_left">
<view class="category_left_item" :class="categoryIndex==index?'categoryActive':''" v-for="(item,index) in categoryList" :key="index"
@click="changeCategory(index)">
{{item}}
<view class="category_left_item" :class="categoryIndex==item.cat_id?'categoryActive':''" v-for="(item,index) in categoryList" :key="item.cat_id"
@click="changeCategory(item.cat_id)">
{{item.cat_name}}
</view>
</view>
<view class="good_body">
<view class="good_title">PICKS FOR YOU</view>
<view class="good_content">
<view class="good_item" v-for="(item,index) in 5" :key="index" @click="goPets">
<view class="good_item_img"></view>
<text>Women Drese</text>
<view class="good_content" v-for="(item,index) in categoryList" :key="item.cat_id" v-show="categoryIndex==item.cat_id">
<view class="good_item" v-for="(item1,index1) in item.subcategories" :key="item1.cat_id" @click="goPets(item1.cat_id)">
<img :src="item1.first_goods_thumb" alt="" class="good_item_img">
<text>{{item1.cat_name}}</text>
</view>
</view>
<view class="good_title">YOU MAY ALSO LIKE</view>
<!-- <view class="good_title">YOU MAY ALSO LIKE</view>
<view class="good_content">
<view class="good_item" v-for="(item,index) in 5" :key="index">
<view class="good_item_img"></view>
<text>Women Drese</text>
</view>
</view>
</view> -->
</view>
</view>
@ -49,6 +49,7 @@
</template>
<script>
import {defaultRequest} from '../../api/index.js'
export default {
data() {
return {
@ -60,11 +61,24 @@
changeCategory(i){
this.categoryIndex=i
},
goPets(){
goPets(id){
uni.navigateTo({
url:"productList"
url:"productList?cat_id="+id+'&type=0'
})
},
getList(){
let data={_action:'getcategorytree'}
defaultRequest(data).then(res=>{
console.info(res)
if(res.error==0){
this.categoryList=res.data
this.categoryIndex=res.data[0].cat_id
}
})
}
},
onShow() {
this.getList()
}
}
</script>

13
pages/category/productList.vue

@ -74,12 +74,15 @@
</template>
<script>
import {defaultRequest} from '../../api/index.js'
export default {
data() {
return {
pets_index:1,
navWidth:"160rpx",
query:{
_action:'getgoods'
},
list: [
{
image: 'https://via.placeholder.com/200x200.png/ff0000',
@ -112,6 +115,14 @@
back(){
uni.navigateBack()
}
},
onLoad(e) {
if(e.type==0){
this.query.cat=e.cat_id
}else{
this.query.keyword=e.keyword
}
}
}
</script>

137
pages/login/index.vue

@ -4,30 +4,32 @@
<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="text" activeColor="#010101" class="select"></uni-segmented-control>
<view class="body">
<view class="login" v-show="current==0">
<input type="text" class="login_input" placeholder="eamil address">
<input type="text" class="login_input" placeholder="password">
<view class="tips">The email address or password you enterde is incorrect.</view>
<input type="text" class="login_input" placeholder="eamil address" v-model="loginDate.username" @input="verificationLogin">
<input type="text" class="login_input" placeholder="password" v-model="loginDate.password" @input="verificationLogin">
<view class="tips" v-show="loginErr">{{errMsg}}</view>
<navigator url="/pages/login/verifyEmail" >
<view class="forgot">Forgot your Password?</view>
</navigator>
<button class="login_submit" >SIGN IN</button>
<button class="login_submit" :disabled="isLogin" @click="login()">SIGN IN</button>
<view class="agreement">
<image src="../../static/img/select2.png" mode="" class="agreement_image"></image>
<view class="">
<image src="../../static/img/select2.png" mode="" class="agreement_image" @click="loginSelect=!loginSelect,loginErr=false" v-show="!loginSelect"></image>
<image src="../../static/img/select1.png" mode="" class="agreement_image" @click="loginSelect=!loginSelect" v-show="loginSelect"></image>
<view class="agreement_right">
by continuong, you agree to be <text class="text"> terms of use </text> and <text class="text"> privacy policy</text>.
</view>
</view>
</view>
<view class="login" v-show="current==1">
<input type="text" class="login_input" placeholder="name">
<input type="text" class="login_input" placeholder="eamil address">
<input type="text" class="login_input" placeholder="password">
<button class="login_submit">REGISTER</button>
<input type="text" class="login_input" placeholder="name" @input="verificationReg" v-model="regDate.username">
<input type="text" class="login_input" placeholder="eamil address" @input="verificationReg" v-model="regDate.email">
<input type="text" class="login_input" placeholder="password" @input="verificationReg" v-model="regDate.password1">
<view class="tips" v-show="regErr">{{errMsg}}</view>
<button class="login_submit" :disabled="isReg" @click="Reg()">REGISTER</button>
<view class="agreement">
<image src="../../static/img/select2.png" mode="" class="agreement_image"></image>
<view class="">
<image src="../../static/img/select2.png" mode="" class="agreement_image" @click="regSelect=!regSelect" v-show="!regSelect"></image>
<image src="../../static/img/select1.png" mode="" class="agreement_image" @click="regSelect=!regSelect" v-show="regSelect"></image>
<view class="agreement_right">
by continuong, you agree to be <text class="text"> terms of use </text> and <text class="text"> privacy policy</text>.
</view>
</view>
@ -42,19 +44,42 @@
</view>
</view>
</view>
<uni-popup ref="alertDialog" type="dialog">
<uni-popup-dialog type="error" cancelText="Close" confirmText="Activation" title="Tips" content="Please activate the mailbox first"
@confirm="dialogConfirm" ></uni-popup-dialog>
</uni-popup>
</view>
</template>
<script>
import {defaultRequest} from '../../api/index.js'
export default {
data() {
return {
items: ['SIGN IN', 'REGISTER'],
current: 0,
dynamicFormData:{
loginDate:{
username:'',
password:'',
_action:'loginbyun'
},
regDate:{
username:'',
email:'',
pwd:''
password1:'',
password2:'',
_action:'registerun'
},
//
isLogin:true,
isReg:true,
//
regSelect:false,
loginSelect:false,
//
loginErr:false,
regErr:false,
errMsg:'The email address or password you enterde is incorrect.',
}
},
methods:{
@ -62,8 +87,87 @@
if (this.current != e.currentIndex) {
this.current = e.currentIndex;
}
},
//
configuration(){
let data={_action:'getpagedata',pagecode:'PAGE-LOGIN'}
defaultRequest(data).then(res=>{
console.info(res)
})
},
//
login(){
if(!this.loginSelect){
this.errMsg='Please read and tick the terms of service and privacy policy first.'
this.loginErr=true
return
}
defaultRequest(this.loginDate).then(res=>{
console.info(res)
if(res.error==0){
this.loginErr=false
}else{
if(res.data){
this.$refs.alertDialog.open()
}else{
this.loginErr=true
this.errMsg=res.message
}
}
})
},
dialogConfirm(){
uni.navigateTo({
url:'verifyEmail?email='+this.loginDate.username
})
},
//
Reg(){
if(!this.regSelect){
uni.showToast({
title:'请先同意并勾选用户协议',
icon:'none',
})
return
}
this.regDate.password2=this.regDate.password1
defaultRequest(this.regDate).then(res=>{
console.info(res)
if(res.error==0){
this.regErr=false
uni.showToast({
title:'注册成功',
icon:'success',
})
}else{
this.regErr=true
this.errMsg=res.message
}
})
},
//
verificationLogin(){
if(this.loginDate.username && this.loginDate.password){
this.isLogin=false
}else{
this.isLogin=true
}
},
//
verificationReg(){
if(this.regDate.username && this.regDate.password1 && this.regDate.email){
this.isReg=false
}else{
this.isReg=true
}
}
},
onLoad() {
this.configuration()
}
}
</script>
@ -126,4 +230,7 @@
}
}
}
.agreement_right{
width: 582rpx;
}
</style>

14
pages/login/verifyEmail.vue

@ -2,10 +2,10 @@
<view>
<view class="login">
<view class="verify_tips">
To verify your email,we've send a verification code to xxxx@xx.com
To verify your email,we've send a verification code to {{email}}
</view>
<input type="text" class="login_input" placeholder="Enter code">
<view class="tips">The code is incorrect.</view>
<view class="tips" v-show="!isErr">The code is incorrect.</view>
<button class="login_submit" @click="isShow=true">CONTINUE</button>
<view class="verify_text">Resend code</view>
</view>
@ -15,7 +15,7 @@
<image src="../../static/img/close.png" mode=""></image>
</view>
<view class="verify_popup_title">Send!</view>
<view class="verify_popup_msg">we send a new verification code to xxxx@xx.com</view>
<view class="verify_popup_msg">we send a new verification code to {{email}}</view>
<view class="verify_popup_btn">
<button>OKAY</button>
</view>
@ -27,11 +27,17 @@
export default {
data() {
return {
isShow:false
isShow:false,
isErr:false,
email:'xxxx@xx.com'
}
},
methods:{
},
onLoad(e) {
console.info(e)
this.email=e.email
}
}
</script>

6191
utils/crypto-js.js

File diff suppressed because it is too large

40
utils/des.js

@ -0,0 +1,40 @@
import CryptoJS from '@/utils/crypto-js.js'
export const encrypt_by_des=(plain_data, key, mode, padding)=> {
try {
var cfg = mode ? {mode: mode} : {mode: CryptoJS.mode.ECB};
if (padding) { cfg.padding = padding; }
var d = CryptoJS.enc.Utf8.parse(plain_data);
var k = CryptoJS.enc.Utf8.parse(key);
var ed1 = CryptoJS.DES.encrypt(d,k,cfg);
var b64 = CryptoJS.enc.Base64.stringify(ed1.ciphertext);
return b64;
} catch (e) {
return '';
}
}
// DES加密
export const encryptDes = (message, key) => {
const keyHex = CryptoJS.enc.Utf8.parse(key);
const encrypted = CryptoJS.DES.encrypt(message, keyHex, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
});
return encrypted.toString();
}
// DES解密
export const decryptDes = (ciphertext, key) => {
const keyHex = CryptoJS.enc.Utf8.parse(key);
// direct decrypt ciphertext
const decrypted = CryptoJS.DES.decrypt({
ciphertext: CryptoJS.enc.Base64.parse(ciphertext)
}, keyHex, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
});
return decrypted.toString(CryptoJS.enc.Utf8);
}
Loading…
Cancel
Save