From cc7a0d5062df15ed1d9db1685719b08fdff4dc23 Mon Sep 17 00:00:00 2001 From: Maoqiang Zheng Date: Tue, 12 Feb 2019 08:54:34 +0800 Subject: [PATCH] change base url to ihome6 --- src/app.js | 2 + .../filteredShopComponent.js | 9 +- .../voucherPosterComponent.js | 3 +- src/pages/allDemanding/allDemanding.js | 3 +- src/pages/grabOrderPage/grabOrderPage.js | 5 +- src/pages/home/home.js | 22 ++-- src/pages/index/index.js | 2 +- src/pages/login/login.js | 124 ++++++++++++++++++ src/pages/login/login.scss | 58 ++++++++ src/pages/shop/shop.js | 4 +- src/serviceAPI.config.js | 8 +- 11 files changed, 212 insertions(+), 28 deletions(-) create mode 100644 src/pages/login/login.js create mode 100644 src/pages/login/login.scss diff --git a/src/app.js b/src/app.js index 5a3962b..f655443 100644 --- a/src/app.js +++ b/src/app.js @@ -20,6 +20,7 @@ class App extends Component { pages: [ //'pages/index/index', // index页面 'pages/home/home',//首页 --------------------- + 'pages/login/login',//登入页面 --------------------- 'pages/shop/shop',//店铺页面 --------------------- 'pages/goods/goods',// 商品页面 --------------------- 'pages/goodsPublish/goodsPublish',// 商品发布页面 --------------------- @@ -35,6 +36,7 @@ class App extends Component { 'pages/myNeedsView/myNeedsView',// 单个需求查看页面 'pages/myNeedsEdit/myNeedsEdit',// 单个需求编辑页面 'pages/myNeedsPublish/myNeedsPublish',// 需求发布 + // 'pages/shopDescription/shopDescription', ], window: { diff --git a/src/component/filteredShopComponent/filteredShopComponent.js b/src/component/filteredShopComponent/filteredShopComponent.js index 6e84df1..4f308e1 100644 --- a/src/component/filteredShopComponent/filteredShopComponent.js +++ b/src/component/filteredShopComponent/filteredShopComponent.js @@ -60,7 +60,8 @@ class recommondShop extends Component { }, header: { 'content-type': 'application/x-www-form-urlencoded', - 'X-Requested-With': 'XMLHttpRequest' + 'X-Requested-With': 'XMLHttpRequest', + 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), } }) .then(res => { @@ -89,7 +90,8 @@ class recommondShop extends Component { }, header: { 'content-type': 'application/x-www-form-urlencoded', - 'X-Requested-With': 'XMLHttpRequest' + 'X-Requested-With': 'XMLHttpRequest', + 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), } }) .then(res => { @@ -115,7 +117,8 @@ class recommondShop extends Component { }, header: { 'content-type': 'application/x-www-form-urlencoded', - 'X-Requested-With': 'XMLHttpRequest' + 'X-Requested-With': 'XMLHttpRequest', + 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), } }) .then(res => { diff --git a/src/component/filteredShopComponent/voucherPosterComponent/voucherPosterComponent.js b/src/component/filteredShopComponent/voucherPosterComponent/voucherPosterComponent.js index 56c99df..da411bc 100644 --- a/src/component/filteredShopComponent/voucherPosterComponent/voucherPosterComponent.js +++ b/src/component/filteredShopComponent/voucherPosterComponent/voucherPosterComponent.js @@ -38,7 +38,8 @@ class VoucherPoster extends Component { }, header: { 'content-type': 'application/x-www-form-urlencoded', - 'X-Requested-With': 'XMLHttpRequest' + 'X-Requested-With': 'XMLHttpRequest', + 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), } }) .then(res => { diff --git a/src/pages/allDemanding/allDemanding.js b/src/pages/allDemanding/allDemanding.js index 9944131..910aeff 100644 --- a/src/pages/allDemanding/allDemanding.js +++ b/src/pages/allDemanding/allDemanding.js @@ -67,7 +67,8 @@ class AllDemanding extends Component { }, header: { 'content-type': 'application/x-www-form-urlencoded', - 'X-Requested-With': 'XMLHttpRequest' + 'X-Requested-With': 'XMLHttpRequest', + 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), } }) .then(res => { diff --git a/src/pages/grabOrderPage/grabOrderPage.js b/src/pages/grabOrderPage/grabOrderPage.js index b1a7206..9b481d4 100644 --- a/src/pages/grabOrderPage/grabOrderPage.js +++ b/src/pages/grabOrderPage/grabOrderPage.js @@ -6,15 +6,12 @@ import { AtModal, AtModalHeader, AtModalContent, AtModalAction, AtIcon } from 't import URL from '../../serviceAPI.config' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' - - import './grabOrderPage.scss' -import { SymbolDef } from '_terser@3.14.1@terser'; class GrabOrderPage extends Component { config = { - navigationBarTitleText: '抢单页面' + navigationBarTitleText: '业主需求' } constructor() { super(...arguments); diff --git a/src/pages/home/home.js b/src/pages/home/home.js index 81e0a08..38fb902 100644 --- a/src/pages/home/home.js +++ b/src/pages/home/home.js @@ -2,7 +2,6 @@ import Taro, { Component } from '@tarojs/taro' import { View, Button, Text, Swiper, SwiperItem, Image, } from '@tarojs/components' import { AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' import FilteredShopComponent from '../../component/filteredShopComponent/filteredShopComponent' -import BottomNav from '../../component/bottomNav/bottomNav' import ScrollToTopComponent from '../../component/scrollToTopComponent/scrollToTopComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' @@ -136,7 +135,6 @@ class Home extends Component { // 异步函数登入api async login() { - Taro.login({ success(res) { if (res.code) { @@ -154,22 +152,24 @@ class Home extends Component { } }) .then(response => { - if (response.data.err_msg === 'success') { - + if (response.data.err_code === 0) { console.log('微信登入成功', response) Taro.setStorageSync('session_id', response.data.session_id) Taro.setStorageSync('shopInfo', response.data.shop_info) Taro.setStorageSync('userInfo', response.data.user_info) - } else { - Taro.showToast({ - title: '登入失败' + response.data.err_msg, - icon: 'none', - duration: 2000 + } else if (response.data.err_code === 888){ + Taro.navigateTo({ + url: '/pages/login/login' }) + }else{ + Taro.showToast({ + title: '登入失败' + response.data.err_msg, + icon: 'none', + duration: 2000 + }) } - } ).catch(err => { console.log('登入微信失败', err) @@ -298,7 +298,6 @@ class Home extends Component { } goToMyNeedsPublish() { Taro.navigateTo({ - url: '/pages/myNeedsPublish/myNeedsPublish' }) @@ -312,6 +311,7 @@ class Home extends Component { await this.login() this.getShops({}) this.getHomeCategoriesInfo() + console.log('didmount') })() diff --git a/src/pages/index/index.js b/src/pages/index/index.js index a435ed0..1209f56 100644 --- a/src/pages/index/index.js +++ b/src/pages/index/index.js @@ -37,7 +37,7 @@ class Index extends Component { // url:'/pages/myNeeds/myNeeds', //url:'/pages/myNeedsPublish/myNeedsPublish' // url:'/pages/mySupplyDemand/mySupplyDemand' - url: '/pages/home/home' + url: '/pages/login/login' // url:'/pages/allDemanding/allDemanding' // url:'/pages/goodsPublish/goodsPublish' diff --git a/src/pages/login/login.js b/src/pages/login/login.js new file mode 100644 index 0000000..54b44a6 --- /dev/null +++ b/src/pages/login/login.js @@ -0,0 +1,124 @@ +import Taro, { Component } from '@tarojs/taro' +import { View,Input,Button,Text,Image } from '@tarojs/components' +import URL from '../../serviceAPI.config' + +import './login.scss' + + + +class Login extends Component { + config = { + navigationBarTitleText: '登入' + } + constructor(){ + this.state={ + username:'', + password:'', + backgroundImage: 'background-image:url(' + URL.Base + '/Public/images/bg3.jpg);' + } + } + + loginApi() { + Taro.request({ + url: URL.Base+'user-login', + method: 'POST', + dataType: 'json', + data: { + username: this.state.username, + password: this.state.password, + + }, + header: { + 'content-type': 'application/x-www-form-urlencoded', + 'X-Requested-With': 'XMLHttpRequest' + } + }) + .then(res => { + console.log('res',res) + if(res.data.err_code===0){ + Taro.showToast({ + title: res.data.msg, + icon: 'success', + duration: 1000 + }) + setTimeout(() => { + Taro.switchTab({ + url: '/pages/home/home' + }) + }, 1000); + + }else{ + Taro.showToast({ + title: res.data.msg, + icon: 'none', + duration: 2000 + }) + } + + }) + + } + + usernameHandler(e){ + let value=e.detail.value + this.setState({username:value}) + } + passwordHandler(e){ + let value=e.detail.value + this.setState({password:value}) + } + loginHandler(){ + this.loginApi() + } + componentDidMount() { + + } + + componentWillReceiveProps(nextProps) { + console.log(this.props, nextProps) + } + + componentWillUnmount() { } + + componentDidShow() { } + + componentDidHide() { } + + render() { + return ( + + + + + + + + 全屋定制商城 + + + + + 用户登入 + + + + + + + + + + 立即注册 + + + + + + + + + ) + } +} + +export default Login diff --git a/src/pages/login/login.scss b/src/pages/login/login.scss new file mode 100644 index 0000000..b34a5a0 --- /dev/null +++ b/src/pages/login/login.scss @@ -0,0 +1,58 @@ + + +.login{ + position: relative; + .background{ + height: 100vh; + } + .logo{ + position: absolute; + top: 0; + height: 200px; + width: 100%; + background-color: #fff; + .image-wrapper{ + display: flex; + flex-wrap: nowrap; + flex-direction: row; + align-items: center; + + .title{ + margin-left: 15%; + font-size: 25rpx + } + } + + + + } + .login-wrapper{ + position: absolute; + background-color: #fff; + width:80%; + top: 30%; + left: 8%; + padding: 2%; + .title{ + font-size: 40rpx + } + .bgtopWrap{ + + margin-top: 10%; + .username{ + + } + .password{ + margin-top: 5% + } + .register{ + float:right; + font-size: 23rpx; + + } + .button{ + margin-top: 10% + } + } + } +} \ No newline at end of file diff --git a/src/pages/shop/shop.js b/src/pages/shop/shop.js index a7df7b8..4b1f3ed 100644 --- a/src/pages/shop/shop.js +++ b/src/pages/shop/shop.js @@ -110,7 +110,8 @@ class Shop extends Component { }, header: { 'content-type': 'application/x-www-form-urlencoded', - 'X-Requested-With': 'XMLHttpRequest' + 'X-Requested-With': 'XMLHttpRequest', + 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), } }) .then(res => { @@ -313,6 +314,7 @@ class Shop extends Component { }, header: { 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), } }) .then(res => { diff --git a/src/serviceAPI.config.js b/src/serviceAPI.config.js index 214f718..8dd018e 100644 --- a/src/serviceAPI.config.js +++ b/src/serviceAPI.config.js @@ -1,5 +1,6 @@ -const LOCALURL = "http://192.168.1.230/" +// const LOCALURL = "http://192.168.1.230/" +const LOCALURL = "https://www.ihome6.com/" const URL = { Base: LOCALURL, Login: LOCALURL + 'Applet-login', //登入接口 @@ -12,16 +13,11 @@ const URL = { GetShopItemDetail: LOCALURL + 'GoodsQuery-ajaxGoodsDetail',// 商品详情 UploadDSPorductImage: LOCALURL + 'Supply-fileUpload',// 上传供求图片 - - //所有业主供求 GetAllDemanding: LOCALURL + 'supply-allDemandList',// 获取所有业主需求 MySupplyDemand: LOCALURL + 'Supply-myList',// 我的供求 supplyDemandDetails: LOCALURL + 'supply-ajaxDemandDetail',// 单个供求详情 - - - // 店铺信息 GoodsSearch: LOCALURL + 'GoodsSearch-search',// 店铺页面的信息 ShopDescription: LOCALURL + 'shop-ajaxShopInfo',// 获取店铺详情