├── pages ├── index │ ├── index.json │ ├── index.js │ ├── index.wxss │ └── index.wxml ├── auth │ └── login │ │ ├── login.json │ │ ├── login.wxml │ │ ├── login.wxss │ │ └── login.js ├── goods │ ├── detail │ │ ├── detail.json │ │ ├── detail.wxml │ │ ├── detail.js │ │ └── detail.wxss │ └── list │ │ ├── list.json │ │ ├── list.wxml │ │ ├── list.wxss │ │ └── list.js ├── member │ └── index │ │ ├── index.json │ │ ├── index.js │ │ ├── index.wxml │ │ └── index.wxss ├── shopping │ └── cart │ │ ├── cart.json │ │ ├── cart.wxml │ │ ├── cart.wxss │ │ └── cart.js └── catalog │ ├── catalog.json │ ├── catalog.wxml │ ├── catalog.wxss │ └── catalog.js ├── images ├── 天猫提示-出错.png ├── icon_bouns.png ├── icon_cart.png ├── icon_delete.png ├── icon_error.png ├── icon_goods.png ├── icon_help.png ├── icon_home.png ├── icon_member.png ├── icon_notice.png ├── icon_right.png ├── icon_search.png ├── icon_address.png ├── icon_catalog.png ├── icon_collect.png ├── icon_integral.png ├── icon_success.png ├── icon_warning.png ├── icon_cart_active.png ├── icon_cart_empty.png ├── icon_home_active.png ├── icon_order_paid.png ├── icon_member_active.png ├── icon_order_comment.png ├── icon_catalog_active.png ├── icon_collect_selected.png ├── icon_order_deliveried.png └── icon_order_delivering.png ├── app.wxss ├── app.js ├── README.md ├── app.json ├── utils └── util.js └── libs └── wxParse ├── wxParse.wxss ├── wxParse.js ├── htmlparser.js ├── wxDiscode.js ├── html2json.js └── wxParse.wxml /pages/index/index.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/auth/login/login.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/goods/detail/detail.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/member/index/index.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/shopping/cart/cart.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /pages/catalog/catalog.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "分类" 3 | } -------------------------------------------------------------------------------- /pages/goods/list/list.json: -------------------------------------------------------------------------------- 1 | { 2 | "navigationBarTitleText": "商品列表" 3 | } -------------------------------------------------------------------------------- /images/天猫提示-出错.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tumobi/eweapp/HEAD/images/天猫提示-出错.png -------------------------------------------------------------------------------- /images/icon_bouns.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tumobi/eweapp/HEAD/images/icon_bouns.png -------------------------------------------------------------------------------- /images/icon_cart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tumobi/eweapp/HEAD/images/icon_cart.png -------------------------------------------------------------------------------- /images/icon_delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tumobi/eweapp/HEAD/images/icon_delete.png -------------------------------------------------------------------------------- /images/icon_error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tumobi/eweapp/HEAD/images/icon_error.png -------------------------------------------------------------------------------- /images/icon_goods.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tumobi/eweapp/HEAD/images/icon_goods.png -------------------------------------------------------------------------------- /images/icon_help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tumobi/eweapp/HEAD/images/icon_help.png -------------------------------------------------------------------------------- /images/icon_home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tumobi/eweapp/HEAD/images/icon_home.png -------------------------------------------------------------------------------- /images/icon_member.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tumobi/eweapp/HEAD/images/icon_member.png -------------------------------------------------------------------------------- /images/icon_notice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tumobi/eweapp/HEAD/images/icon_notice.png -------------------------------------------------------------------------------- /images/icon_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tumobi/eweapp/HEAD/images/icon_right.png -------------------------------------------------------------------------------- /images/icon_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tumobi/eweapp/HEAD/images/icon_search.png -------------------------------------------------------------------------------- /images/icon_address.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tumobi/eweapp/HEAD/images/icon_address.png -------------------------------------------------------------------------------- /images/icon_catalog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tumobi/eweapp/HEAD/images/icon_catalog.png -------------------------------------------------------------------------------- /images/icon_collect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tumobi/eweapp/HEAD/images/icon_collect.png -------------------------------------------------------------------------------- /images/icon_integral.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tumobi/eweapp/HEAD/images/icon_integral.png -------------------------------------------------------------------------------- /images/icon_success.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tumobi/eweapp/HEAD/images/icon_success.png -------------------------------------------------------------------------------- /images/icon_warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tumobi/eweapp/HEAD/images/icon_warning.png -------------------------------------------------------------------------------- /images/icon_cart_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tumobi/eweapp/HEAD/images/icon_cart_active.png -------------------------------------------------------------------------------- /images/icon_cart_empty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tumobi/eweapp/HEAD/images/icon_cart_empty.png -------------------------------------------------------------------------------- /images/icon_home_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tumobi/eweapp/HEAD/images/icon_home_active.png -------------------------------------------------------------------------------- /images/icon_order_paid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tumobi/eweapp/HEAD/images/icon_order_paid.png -------------------------------------------------------------------------------- /images/icon_member_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tumobi/eweapp/HEAD/images/icon_member_active.png -------------------------------------------------------------------------------- /images/icon_order_comment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tumobi/eweapp/HEAD/images/icon_order_comment.png -------------------------------------------------------------------------------- /images/icon_catalog_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tumobi/eweapp/HEAD/images/icon_catalog_active.png -------------------------------------------------------------------------------- /images/icon_collect_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tumobi/eweapp/HEAD/images/icon_collect_selected.png -------------------------------------------------------------------------------- /images/icon_order_deliveried.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tumobi/eweapp/HEAD/images/icon_order_deliveried.png -------------------------------------------------------------------------------- /images/icon_order_delivering.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tumobi/eweapp/HEAD/images/icon_order_delivering.png -------------------------------------------------------------------------------- /pages/auth/login/login.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 | 9 | 忘记密码了? 10 | 新用户注册 11 | 12 |
13 |
14 |
-------------------------------------------------------------------------------- /app.wxss: -------------------------------------------------------------------------------- 1 | /**app.wxss**/ 2 | page{ 3 | background: #f4f4f4; 4 | color: #333; 5 | font-size: 14px; 6 | min-height: 100%; 7 | } 8 | 9 | view, text, image, navigator, input, button{ 10 | box-sizing: border-box; 11 | } 12 | 13 | .container { 14 | min-height: 100%; 15 | box-sizing: border-box; 16 | background: #f4f4f4; 17 | } 18 | 19 | .list-empty{ 20 | height: 100%; 21 | width: 100%; 22 | display: flex; 23 | justify-content: center; 24 | flex-direction: column; 25 | align-items: center; 26 | } 27 | 28 | .list-empty .icon{ 29 | height: 200rpx; 30 | width: 200rpx; 31 | } 32 | 33 | .list-empty .msg{ 34 | line-height: 40rpx; 35 | font-size: 12px; 36 | color: #999; 37 | } 38 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | //app.js 2 | App({ 3 | onLaunch: function() { 4 | //调用API从本地缓存中获取数据 5 | var logs = wx.getStorageSync('logs') || [] 6 | logs.unshift(Date.now()) 7 | wx.setStorageSync('logs', logs) 8 | }, 9 | 10 | getUserInfo: function(cb) { 11 | var that = this 12 | if (this.globalData.userInfo) { 13 | typeof cb == "function" && cb(this.globalData.userInfo) 14 | } else { 15 | //调用登录接口 16 | wx.getUserInfo({ 17 | withCredentials: false, 18 | success: function(res) { 19 | that.globalData.userInfo = res.userInfo 20 | typeof cb == "function" && cb(that.globalData.userInfo) 21 | } 22 | }) 23 | } 24 | }, 25 | 26 | globalData: { 27 | userInfo: null 28 | } 29 | }) 30 | -------------------------------------------------------------------------------- /pages/catalog/catalog.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | {{item.name}} 11 | 12 | {{sitem.name}} 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /pages/auth/login/login.wxss: -------------------------------------------------------------------------------- 1 | /* login.wxss */ 2 | page, .container{ 3 | height: 100%; 4 | background: #fff; 5 | } 6 | 7 | .login{ 8 | padding: 100rpx 30rpx 0 30rpx; 9 | width: 100%; 10 | height: 100%; 11 | overflow: hidden; 12 | background: #fff; 13 | } 14 | 15 | .login .input-item{ 16 | width: 690rpx; 17 | height: 68rpx; 18 | border: 1px solid #e6e6e6; 19 | margin: 40rpx 0; 20 | padding-left: 20rpx; 21 | line-height: 68rpx; 22 | font-size: 14px; 23 | color: #666; 24 | } 25 | 26 | .login .btn-item{ 27 | width: 690rpx; 28 | height: 68rpx; 29 | background: #d81e06; 30 | margin-top: 40rpx; 31 | text-align: center; 32 | line-height: 68rpx; 33 | font-size: 14px; 34 | color: #fff; 35 | border-radius: 0; 36 | border: none; 37 | } 38 | 39 | .login .link-item{ 40 | margin-top: 20rpx; 41 | height: 40rpx; 42 | line-height: 40rpx; 43 | color: #999; 44 | font-size: 12px; 45 | } 46 | 47 | .login .link-item .l{ 48 | float: left; 49 | } 50 | 51 | .login .link-item .r{ 52 | float: right; 53 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # eweapp 2 | ECShop非官方版微信小程序商城,基于3.6版本appserver接口,100%兼容原有程序,没有对原有程序代码进行过任何改动。 3 | > 注意:本项目还在开发中,功能还未完善,请匆商用。 4 | 5 | # 实时更新地址 6 | GitHub: https://github.com/tumobi/eweapp 7 | 如果您觉得不错,欢迎star。 8 | 9 | # 功能列表 10 | + [x] 首页: 轮播图、商城滚动公告、精品推荐、新品上市、销量排行 11 | + [x] 分类:商品搜索功能、分类目录展示 12 | + [x] 我的:退出登录功能、用户信息显示、订单统计 13 | + [x] 商品列表:排序功能、底部加载更多商品 14 | + [x] 商品详情:规格数量选择、加入购物车、收藏功能、关联商品 15 | + [ ] 登录:用户名或邮箱登录、用户注册、找回密码 16 | + [ ] 购物车:购物车商品规格数量修改、删除、下单支付 17 | + [ ] 订单中心:订单列表、详单详情、物流信息 18 | + [ ] 红包/优惠券 19 | + [ ] 收货地址 20 | + [ ] 其它功能正在开发中... 21 | 22 | # 界面预览 23 | 24 | ![首页](http://upload-images.jianshu.io/upload_images/3985656-ae862448d3f72f48.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 25 | 26 | ![我的](http://upload-images.jianshu.io/upload_images/3985656-1669a945af436074.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 27 | 28 | ![商品列表](http://upload-images.jianshu.io/upload_images/3985656-549cd2c55efae115.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 29 | 30 | # 交流反馈 31 | QQ 群:490201793 32 | 33 | 公众号:nideshop 34 | 35 | # 关于商用 36 | 由于本项目使用到ECShop 3.6 appserver接口开发,如要用于商业用途,请先取得ECShop的授权。 37 | -------------------------------------------------------------------------------- /pages/catalog/catalog.wxss: -------------------------------------------------------------------------------- 1 | /* catalog.wxss */ 2 | page{ 3 | background: #f4f4f4; 4 | } 5 | 6 | .search{ 7 | width: 100%; 8 | height: 150rpx; 9 | background: #fff; 10 | display: flex; 11 | justify-content: center; 12 | align-items: center; 13 | } 14 | 15 | .search .form{ 16 | height: 60rpx; 17 | width: 690rpx; 18 | background: #f4f4f4; 19 | border-radius: 30rpx; 20 | display: flex; 21 | justify-content: center; 22 | align-items: center; 23 | } 24 | 25 | .search .input{ 26 | height: 40rpx; 27 | width: 600rpx; 28 | } 29 | 30 | .search .btn{ 31 | height: 40rpx; 32 | width: 40rpx; 33 | } 34 | 35 | .catalog{ 36 | margin-top: 20rpx; 37 | background: #f4f4f4; 38 | } 39 | 40 | .catalog .item{ 41 | margin-bottom: 20rpx; 42 | background: #fff; 43 | } 44 | 45 | .catalog .item .h{ 46 | height: 100rpx; 47 | text-align: center; 48 | line-height: 100rpx; 49 | } 50 | 51 | .catalog .item .b{ 52 | height: auto; 53 | overflow: hidden; 54 | padding: 0 10rpx; 55 | } 56 | 57 | .catalog .item .a{ 58 | display: block; 59 | float: left; 60 | font-size: 12px; 61 | color: #666; 62 | margin: 0 10rpx 20rpx 10rpx; 63 | border: 1px solid #f4f4f4; 64 | padding:10rpx 20rpx; 65 | } -------------------------------------------------------------------------------- /pages/index/index.js: -------------------------------------------------------------------------------- 1 | //index.js 2 | const util = require('../../utils/util.js'); 3 | 4 | //获取应用实例 5 | var app = getApp() 6 | Page({ 7 | data: { 8 | banners: [], 9 | notices: [], 10 | goodProducts: [], 11 | hotProducts: [], 12 | recentlyProducts: [], 13 | }, 14 | 15 | onLoad: function () { 16 | wx.showLoading({ 17 | title: '', 18 | }); 19 | this.getBanner(); 20 | this.getNotices(); 21 | this.getPorducts(); 22 | }, 23 | getBanner() { 24 | util.request(util.apiUrl + 'ecapi.banner.list', 'POST').then((res) => { 25 | this.setData({ 26 | banners: res.banners 27 | }) 28 | }); 29 | }, 30 | getNotices() { 31 | util.request(util.apiUrl + 'ecapi.notice.list', 'POST', { 32 | page: 1, 33 | per_page: 5 34 | }).then((res) => { 35 | this.setData({ 36 | notices: res.notices 37 | }); 38 | }); 39 | }, 40 | getPorducts() { 41 | util.request(util.apiUrl + 'ecapi.home.product.list', 'POST').then((res) => { 42 | this.setData({ 43 | goodProducts: res.good_products, 44 | hotProducts: res.hot_products, 45 | recentlyProducts: res.recently_products 46 | }); 47 | wx.hideLoading(); 48 | }).catch(err => { 49 | wx.hideLoading(); 50 | }); 51 | } 52 | }) 53 | -------------------------------------------------------------------------------- /pages/goods/list/list.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 综合 7 | 8 | 9 | 销量 10 | 11 | 12 | 新品 13 | 14 | 15 | 价格 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | {{item.name}} 24 | ¥{{item.current_price}} 25 | 26 | 27 | 28 | 29 | 30 | 找到不商品 31 | 32 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages": [ 3 | "pages/index/index", 4 | "pages/goods/detail/detail", 5 | "pages/member/index/index", 6 | "pages/goods/list/list", 7 | "pages/catalog/catalog", 8 | "pages/shopping/cart/cart", 9 | "pages/auth/login/login" 10 | ], 11 | "window": { 12 | "backgroundTextStyle": "light", 13 | "navigationBarBackgroundColor": "#fafafa", 14 | "navigationBarTitleText": "ecshop小程序商城", 15 | "navigationBarTextStyle": "black" 16 | }, 17 | "tabBar": { 18 | "color": "#2c2c2c", 19 | "selectedColor": "#d81e06", 20 | "backgroundColor": "#fafafa", 21 | "borderStyle": "white", 22 | "list": [ 23 | { 24 | "pagePath": "pages/index/index", 25 | "text": "首页", 26 | "iconPath": "images/icon_home.png", 27 | "selectedIconPath": "images/icon_home_active.png" 28 | }, 29 | { 30 | "pagePath": "pages/catalog/catalog", 31 | "text": "分类", 32 | "iconPath": "images/icon_catalog.png", 33 | "selectedIconPath": "images/icon_catalog_active.png" 34 | }, 35 | { 36 | "pagePath": "pages/shopping/cart/cart", 37 | "text": "购物车", 38 | "iconPath": "images/icon_cart.png", 39 | "selectedIconPath": "images/icon_cart_active.png" 40 | }, 41 | { 42 | "pagePath": "pages/member/index/index", 43 | "text": "我的", 44 | "iconPath": "images/icon_member.png", 45 | "selectedIconPath": "images/icon_member_active.png" 46 | } 47 | ] 48 | } 49 | } -------------------------------------------------------------------------------- /pages/catalog/catalog.js: -------------------------------------------------------------------------------- 1 | // catalog.js 2 | const util = require('../../utils/util.js') 3 | 4 | Page({ 5 | 6 | /** 7 | * 页面的初始数据 8 | */ 9 | data: { 10 | keyword: '', 11 | categories: [] 12 | }, 13 | 14 | /** 15 | * 生命周期函数--监听页面加载 16 | */ 17 | onLoad: function (options) { 18 | this.getCategories(); 19 | }, 20 | 21 | bindKeywordConfirm(event){ 22 | this.setData({ 23 | keyword: event.detail.value 24 | }) 25 | 26 | this.bindSearchTap(); 27 | }, 28 | 29 | bindKeywordInput(event){ 30 | this.setData({ 31 | keyword: event.detail.value 32 | }) 33 | }, 34 | 35 | /** 36 | * 点击搜索 37 | */ 38 | bindSearchTap(){ 39 | wx.navigateTo({ 40 | url: '/pages/goods/list/list?keyword='+ this.data.keyword, 41 | }) 42 | }, 43 | 44 | getCategories() { 45 | util.request(util.apiUrl + 'ecapi.category.list', 'POST', { 46 | page: 1, 47 | per_page: 100 48 | }).then((res) => { 49 | console.log(res.categories) 50 | this.setData({ 51 | categories: res.categories 52 | }) 53 | }); 54 | }, 55 | 56 | /** 57 | * 生命周期函数--监听页面初次渲染完成 58 | */ 59 | onReady: function () { 60 | 61 | }, 62 | 63 | /** 64 | * 生命周期函数--监听页面显示 65 | */ 66 | onShow: function () { 67 | 68 | }, 69 | 70 | /** 71 | * 生命周期函数--监听页面隐藏 72 | */ 73 | onHide: function () { 74 | 75 | }, 76 | 77 | /** 78 | * 生命周期函数--监听页面卸载 79 | */ 80 | onUnload: function () { 81 | 82 | }, 83 | 84 | /** 85 | * 页面相关事件处理函数--监听用户下拉动作 86 | */ 87 | onPullDownRefresh: function () { 88 | 89 | }, 90 | 91 | /** 92 | * 页面上拉触底事件的处理函数 93 | */ 94 | onReachBottom: function () { 95 | 96 | }, 97 | 98 | /** 99 | * 用户点击右上角分享 100 | */ 101 | onShareAppMessage: function () { 102 | 103 | } 104 | }) -------------------------------------------------------------------------------- /pages/shopping/cart/cart.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 您的购物车没有商品 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | {{item.product.name}} 18 | 19 | 20 | {{item.property}} 21 | 22 | ¥{{item.price}} 23 | 24 | - 25 | 26 | + 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 全选({{cartTotal.checkedGoodsCount}}) 37 | {{'¥' + cartTotal.checkedGoodsAmount}} 38 | 去结算 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /utils/util.js: -------------------------------------------------------------------------------- 1 | const apiUrl = 'http://api.ecshop.dev/v2/'; //接口地址 2 | 3 | function formatTime(date) { 4 | var year = date.getFullYear() 5 | var month = date.getMonth() + 1 6 | var day = date.getDate() 7 | 8 | var hour = date.getHours() 9 | var minute = date.getMinutes() 10 | var second = date.getSeconds() 11 | 12 | 13 | return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':') 14 | } 15 | 16 | function formatNumber(n) { 17 | n = n.toString() 18 | return n[1] ? n : '0' + n 19 | } 20 | 21 | 22 | function request(url, method = 'GET', data = {}) { 23 | 24 | let header = { 25 | 'content-type': 'application/json', 26 | 'X-ECAPI-Sign': '', 27 | 'X-ECAPI-UDID': '', 28 | 'X-ECAPI-UserAgent': 'Platform/Wechat', 29 | 'X-ECAPI-Ver': '1.1.0' 30 | }; 31 | 32 | let token = wx.getStorageSync('token') || ''; 33 | if (token) { 34 | header['X-ECAPI-Authorization'] = token 35 | } 36 | 37 | return new Promise(function (resolve, reject) { 38 | wx.request({ 39 | url: url, 40 | method: method, 41 | data: data, 42 | header: header, 43 | success: function (res) { 44 | if (res.data.error_code === 0) { 45 | resolve(res.data); 46 | } else { 47 | reject(res.data); 48 | } 49 | }, 50 | fail: function (err) { 51 | wx.showToast({ 52 | title: '网络加载失败', 53 | }); 54 | } 55 | }); 56 | }); 57 | } 58 | 59 | 60 | function showToast(title, type = 'error') { 61 | let image = ''; 62 | switch (type) { 63 | case 'error': 64 | image = '/images/icon_error.png' 65 | break; 66 | case 'success': 67 | image = '/images/icon_success.png' 68 | break; 69 | case 'warning': 70 | image = '/images/icon_warning.png' 71 | break; 72 | } 73 | wx.showToast({ 74 | title: title, 75 | image: image, 76 | duration: 0, 77 | mask: true, 78 | success: function (res) { }, 79 | fail: function (res) { }, 80 | complete: function (res) { }, 81 | }) 82 | } 83 | 84 | module.exports = { 85 | formatTime: formatTime, 86 | request: request, 87 | showToast: showToast, 88 | apiUrl: apiUrl, 89 | } 90 | 91 | -------------------------------------------------------------------------------- /pages/auth/login/login.js: -------------------------------------------------------------------------------- 1 | // login.js 2 | const util = require('../../../utils/util.js'); 3 | 4 | Page({ 5 | 6 | /** 7 | * 页面的初始数据 8 | */ 9 | data: { 10 | username: '', 11 | password: '' 12 | }, 13 | 14 | /** 15 | * 生命周期函数--监听页面加载 16 | */ 17 | onLoad: function (options) { 18 | }, 19 | 20 | formSubmit: function (e) { 21 | this.login(); 22 | }, 23 | 24 | bindUsernameInput: function (e) { 25 | this.setData({ 26 | username: e.detail.value 27 | }) 28 | }, 29 | 30 | bindPasswordInput: function (e) { 31 | this.setData({ 32 | password: e.detail.value 33 | }) 34 | }, 35 | 36 | login() { 37 | 38 | if (this.data.username.length <=0) { 39 | util.showToast('请输入用户名') 40 | return false; 41 | } 42 | 43 | if (this.data.password.length <= 0) { 44 | util.showToast('请输入密码') 45 | return false; 46 | } 47 | 48 | util.request(util.apiUrl + 'ecapi.auth.signin', 'POST', { 49 | username: this.data.username, 50 | password: this.data.password 51 | }).then((res) => { 52 | this.setData({ 53 | token: res.token, 54 | user: res.user 55 | }); 56 | 57 | wx.setStorageSync('token', res.token); 58 | wx.setStorageSync('user', res.user); 59 | 60 | //跳转到一个页面 61 | wx.navigateBack({ 62 | 63 | }) 64 | 65 | }).catch(err => { 66 | util.showToast('登录失败') 67 | }); 68 | }, 69 | 70 | /** 71 | * 生命周期函数--监听页面初次渲染完成 72 | */ 73 | onReady: function () { 74 | 75 | }, 76 | 77 | /** 78 | * 生命周期函数--监听页面显示 79 | */ 80 | onShow: function () { 81 | 82 | }, 83 | 84 | /** 85 | * 生命周期函数--监听页面隐藏 86 | */ 87 | onHide: function () { 88 | 89 | }, 90 | 91 | /** 92 | * 生命周期函数--监听页面卸载 93 | */ 94 | onUnload: function () { 95 | 96 | }, 97 | 98 | /** 99 | * 页面相关事件处理函数--监听用户下拉动作 100 | */ 101 | onPullDownRefresh: function () { 102 | 103 | }, 104 | 105 | /** 106 | * 页面上拉触底事件的处理函数 107 | */ 108 | onReachBottom: function () { 109 | 110 | }, 111 | 112 | /** 113 | * 用户点击右上角分享 114 | */ 115 | onShareAppMessage: function () { 116 | 117 | } 118 | }) -------------------------------------------------------------------------------- /pages/member/index/index.js: -------------------------------------------------------------------------------- 1 | // index.js 2 | const util = require('../../../utils/util.js'); 3 | 4 | Page({ 5 | 6 | /** 7 | * 页面的初始数据 8 | */ 9 | data: { 10 | user: { 11 | id: 0, 12 | username: 'Hi 你好', 13 | avatar: '' 14 | }, 15 | orderTotal: { 16 | "created": 0, 17 | "paid": 0, 18 | "delivering": 0, 19 | "deliveried": 0, 20 | "finished": 0, 21 | "cancelled": 0 22 | } 23 | }, 24 | 25 | /** 26 | * 生命周期函数--监听页面加载 27 | */ 28 | onLoad: function (options) { 29 | 30 | }, 31 | 32 | logout (){ 33 | wx.removeStorageSync('token'); 34 | wx.removeStorageSync('user'); 35 | util.showToast('退出登录成功', 'success'); 36 | setTimeout(function(){ 37 | wx.switchTab({ 38 | url: '/pages/index/index', 39 | }) 40 | }, 1500) 41 | }, 42 | 43 | /** 44 | * 设置会员信息 45 | */ 46 | setUserInfo() { 47 | let user = wx.getStorageSync('user'); 48 | this.setData({ 49 | user: user 50 | }) 51 | }, 52 | 53 | /** 54 | * 获取订单数量 55 | */ 56 | getOrderTotal() { 57 | util.request(util.apiUrl + 'ecapi.order.subtotal', 'POST').then((res) => { 58 | this.setData({ 59 | orderTotal: res.subtotal, 60 | }); 61 | }); 62 | }, 63 | 64 | /** 65 | * 绑定用用户名和头像的事件 66 | */ 67 | bindUserTap() { 68 | 69 | if (wx.getStorageSync('token')) { 70 | //个人信息页面 71 | } else { 72 | //跳转到登录页面 73 | wx.navigateTo({ 74 | url: '/pages/auth/login/login', 75 | }); 76 | } 77 | 78 | 79 | }, 80 | 81 | /** 82 | * 生命周期函数--监听页面初次渲染完成 83 | */ 84 | onReady: function () { 85 | 86 | }, 87 | 88 | /** 89 | * 生命周期函数--监听页面显示 90 | */ 91 | onShow: function () { 92 | this.setUserInfo(); 93 | this.getOrderTotal(); 94 | }, 95 | 96 | /** 97 | * 生命周期函数--监听页面隐藏 98 | */ 99 | onHide: function () { 100 | 101 | }, 102 | 103 | /** 104 | * 生命周期函数--监听页面卸载 105 | */ 106 | onUnload: function () { 107 | 108 | }, 109 | 110 | /** 111 | * 页面相关事件处理函数--监听用户下拉动作 112 | */ 113 | onPullDownRefresh: function () { 114 | 115 | }, 116 | 117 | /** 118 | * 页面上拉触底事件的处理函数 119 | */ 120 | onReachBottom: function () { 121 | 122 | }, 123 | 124 | /** 125 | * 用户点击右上角分享 126 | */ 127 | onShareAppMessage: function () { 128 | 129 | } 130 | }) -------------------------------------------------------------------------------- /pages/goods/list/list.wxss: -------------------------------------------------------------------------------- 1 | /* list.wxss */ 2 | page, .container{ 3 | background: #fff; 4 | min-height: 100%; 5 | } 6 | .sort{ 7 | position: fixed; 8 | background: #fff; 9 | width: 100%; 10 | height: 78rpx; 11 | } 12 | 13 | .sort-box{ 14 | background: #fff; 15 | width: 100%; 16 | height: 78rpx; 17 | overflow: hidden; 18 | padding: 0 30rpx; 19 | display: flex; 20 | border-bottom: 1px solid #d9d9d9; 21 | } 22 | 23 | .sort-box .item{ 24 | height: 78rpx; 25 | line-height: 78rpx; 26 | text-align: center; 27 | flex:1; 28 | color: #333; 29 | font-size: 30rpx; 30 | } 31 | 32 | .sort-box .item .txt{ 33 | display: block; 34 | width: 100%; 35 | height: 100%; 36 | color: #333; 37 | } 38 | 39 | .sort-box .item.active .txt{ 40 | color: #b4282d; 41 | } 42 | 43 | .sort-box .item.by-price{ 44 | background: url(//yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/no-3127092a69.png) 155rpx center no-repeat; 45 | background-size: 15rpx 21rpx; 46 | } 47 | 48 | .sort-box .item.by-price.active.asc{ 49 | background: url(http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/up-636b92c0a5.png) 155rpx center no-repeat; 50 | background-size: 15rpx 21rpx; 51 | } 52 | 53 | .sort-box .item.by-price.active.desc{ 54 | background: url(http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/down-95e035f3e5.png) 155rpx center no-repeat; 55 | background-size: 15rpx 21rpx; 56 | } 57 | 58 | .goods-section{ 59 | padding-top: 88rpx; 60 | background: #fff; 61 | height: auto; 62 | overflow: hidden; 63 | } 64 | 65 | .goods-section .b{ 66 | padding: 10rpx; 67 | 68 | } 69 | 70 | .goods-section .item{ 71 | float: left; 72 | width: 345rpx; 73 | margin: 0 10rpx 40rpx 10rpx; 74 | } 75 | 76 | .goods-section .thumb{ 77 | width: 345rpx; 78 | height: 345rpx; 79 | } 80 | 81 | .goods-section .name{ 82 | margin-top: 10rpx; 83 | width: 345rpx; 84 | height: 26px; 85 | line-height: 26px; 86 | overflow: hidden; 87 | text-overflow: ellipsis; 88 | white-space: nowrap; 89 | font-size: 14px; 90 | color: #333; 91 | text-align: center; 92 | } 93 | 94 | .goods-section .price{ 95 | width: 345rpx; 96 | height: 20px; 97 | line-height: 20px; 98 | text-align: center; 99 | font-size: 14px; 100 | color: #d81e06; 101 | } 102 | 103 | .list-empty{ 104 | margin-top: 40%; 105 | } -------------------------------------------------------------------------------- /pages/index/index.wxss: -------------------------------------------------------------------------------- 1 | /**index.wxss**/ 2 | .banner{ 3 | height: 378rpx; 4 | width: 100%; 5 | } 6 | 7 | .banner .slide-image{ 8 | height: 378rpx; 9 | width: 750rpx; 10 | } 11 | 12 | .menu{ 13 | width: 100%; 14 | height: 180rpx; 15 | background: #fff; 16 | display: flex; 17 | justify-content: space-around; 18 | align-items: center; 19 | flex-direction: row; 20 | } 21 | 22 | .menu .item{ 23 | height: 100%; 24 | display: flex; 25 | justify-content: center; 26 | align-items: center; 27 | flex-direction: column; 28 | } 29 | 30 | .menu .icon{ 31 | height: 88rpx; 32 | width: 88rpx; 33 | } 34 | 35 | .menu .name{ 36 | line-height: 24px; 37 | font-size: 14px; 38 | } 39 | 40 | .notice{ 41 | /* border-top: 1rpx solid #ececec; */ 42 | height: 80rpx; 43 | width: 100%; 44 | background: #fff; 45 | display: flex; 46 | flex-direction: row; 47 | align-items: center; 48 | padding: 0 20rpx; 49 | margin-bottom: 20rpx; 50 | } 51 | 52 | .notice .icon{ 53 | height: 44rpx; 54 | width: 44rpx; 55 | } 56 | 57 | .notice-list { 58 | width: 80vw; 59 | margin-left: 20rpx; 60 | border-left: 1px solid #f4f4f4; 61 | height: 30rpx; 62 | flex: 1; 63 | font-size: 12px; 64 | padding-left: 20rpx; 65 | color: #333; 66 | } 67 | 68 | .notice-list .swiper_item { 69 | font-size: 14px; 70 | overflow: hidden; 71 | text-overflow: ellipsis; 72 | white-space: nowrap; 73 | } 74 | 75 | .goods-section{ 76 | width: 100%; 77 | height: auto; 78 | overflow: hidden; 79 | background: #fff; 80 | margin-bottom: 20rpx; 81 | } 82 | 83 | .goods-section .h{ 84 | height: 120rpx; 85 | line-height: 120rpx; 86 | color: #333; 87 | font-size: 14px; 88 | text-align: center; 89 | } 90 | 91 | .goods-section .b{ 92 | padding: 10rpx; 93 | } 94 | 95 | .goods-section .item{ 96 | float: left; 97 | width: 345rpx; 98 | margin: 0 10rpx 40rpx 10rpx; 99 | } 100 | 101 | .goods-section .thumb{ 102 | width: 345rpx; 103 | height: 345rpx; 104 | } 105 | 106 | .goods-section .name{ 107 | margin-top: 10rpx; 108 | width: 345rpx; 109 | height: 26px; 110 | line-height: 26px; 111 | overflow: hidden; 112 | text-overflow: ellipsis; 113 | white-space: nowrap; 114 | font-size: 14px; 115 | color: #333; 116 | text-align: center; 117 | } 118 | 119 | .goods-section .price{ 120 | width: 345rpx; 121 | height: 20px; 122 | line-height: 20px; 123 | text-align: center; 124 | font-size: 14px; 125 | color: #d81e06; 126 | } -------------------------------------------------------------------------------- /pages/member/index/index.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {{user.username || 'Hi 你好'}} 6 | 7 | 8 | 9 | 我的订单 10 | 11 | 12 | 13 | 14 | 15 | 待付款 16 | {{orderTotal.paid}} 17 | 18 | 19 | 20 | 待发货 21 | {{orderTotal.delivering}} 22 | 23 | 24 | 25 | 待收货 26 | {{orderTotal.deliveried}} 27 | 28 | 29 | 30 | 待评论 31 | {{orderTotal.finished}} 32 | 33 | 34 | 35 | 36 | 37 | 38 | 我的收藏 39 | 40 | 41 | 42 | 43 | 红包/优惠券 44 | 45 | 46 | 47 | 48 | 收货地址 49 | 50 | 51 | 52 | 53 | 积分记录 54 | 55 | 56 | 57 | 退出登录 58 | -------------------------------------------------------------------------------- /pages/member/index/index.wxss: -------------------------------------------------------------------------------- 1 | /* index.wxss */ 2 | .container{ 3 | height: 100%; 4 | overflow: hidden; 5 | } 6 | .user-box{ 7 | background: #333; 8 | height: 400rpx; 9 | display: flex; 10 | flex-direction: column; 11 | align-items: center; 12 | justify-content: center; 13 | } 14 | 15 | .user-box .avatar{ 16 | width: 140rpx; 17 | height: 140rpx; 18 | border-radius: 50%; 19 | } 20 | 21 | .user-box .username{ 22 | margin-top: 30rpx; 23 | font-size: 14px; 24 | color: #fff; 25 | } 26 | 27 | .order{ 28 | height: auto; 29 | overflow: hidden; 30 | background: #fff; 31 | } 32 | 33 | .order .h{ 34 | height: 108rpx; 35 | padding-left: 30rpx; 36 | padding-right: 20rpx; 37 | border-bottom: 1px solid #e6e6e6; 38 | display: flex; 39 | align-items: center; 40 | } 41 | 42 | .order .h .label{ 43 | flex: 1; 44 | } 45 | 46 | .order .h .icon-go{ 47 | width: 44rpx; 48 | height: 44rpx; 49 | } 50 | 51 | .order .b{ 52 | height: 168rpx; 53 | display: flex; 54 | } 55 | 56 | .order .b .item{ 57 | width: 25%; 58 | height: 100%; 59 | position: relative; 60 | display: flex; 61 | flex-direction: column; 62 | justify-content: center; 63 | align-items: center; 64 | } 65 | 66 | .order .b .icon{ 67 | width: 72rpx; 68 | height: 72rpx; 69 | } 70 | 71 | .order .b .label{ 72 | font-size: 12px; 73 | color: #666; 74 | } 75 | 76 | .order .b .count{ 77 | position: absolute; 78 | top: 20rpx; 79 | display: block; 80 | right: 40rpx; 81 | font-size: 12px; 82 | min-width: 16px; 83 | height: 16px; 84 | text-align: center; 85 | line-height: 14px; 86 | border-radius: 8px; 87 | border: 1px solid #d81e06; 88 | color: #d81e06; 89 | } 90 | 91 | .section-menu{ 92 | background: #fff; 93 | height: auto; 94 | overflow: hidden; 95 | margin-top: 20rpx; 96 | margin-bottom: 20rpx; 97 | } 98 | 99 | .section-menu .item{ 100 | height: 108rpx; 101 | width: 100%; 102 | display: flex; 103 | align-items: center; 104 | border-bottom: 1px solid #e6e6e6; 105 | padding: 0 20rpx; 106 | } 107 | 108 | .section-menu .item:last-child{ 109 | border-bottom: 1px solid #fff; 110 | } 111 | 112 | .section-menu .item .icon{ 113 | width: 44rpx; 114 | height: 44rpx; 115 | } 116 | 117 | .section-menu .item .label{ 118 | margin-left: 10rpx; 119 | flex: 1; 120 | font-size: 12px; 121 | } 122 | 123 | .section-menu .item .icon-go{ 124 | width: 44rpx; 125 | height: 44rpx; 126 | } 127 | 128 | .logout{ 129 | margin-bottom: 20rpx; 130 | width: 100%; 131 | height: 108rpx; 132 | background: #fff; 133 | text-align: center; 134 | line-height: 108rpx; 135 | } -------------------------------------------------------------------------------- /pages/goods/list/list.js: -------------------------------------------------------------------------------- 1 | // list.js 2 | const util = require('../../../utils/util.js'); 3 | 4 | Page({ 5 | 6 | /** 7 | * 页面的初始数据 8 | */ 9 | data: { 10 | requestLoading: true, 11 | category: 0, 12 | keyword: '', 13 | products: [], 14 | paged: { 15 | page: 1, 16 | size: 10 17 | }, 18 | sort_key: 0, 19 | sort_value: 0, 20 | }, 21 | 22 | /** 23 | * 排序事件 24 | */ 25 | bindSorderTap(event) { 26 | let sort_key = event.currentTarget.id 27 | this.setData({ 28 | 'paged.page': 1, 29 | sort_key: sort_key 30 | }); 31 | 32 | if (sort_key == 1) { 33 | this.setData({ 34 | sort_value: this.data.sort_value == 1 ? 2 : 1 35 | }) 36 | } 37 | 38 | this.getPorducts(); 39 | }, 40 | 41 | getPorducts(loadMore = false) { 42 | wx.showLoading({ 43 | title: '加载中...', 44 | }) 45 | util.request(util.apiUrl + 'ecapi.product.list', 'POST', { 46 | category: this.data.category, 47 | page: this.data.paged.page, 48 | keyword: this.data.keyword, 49 | per_page: this.data.paged.size, 50 | sort_key: this.data.sort_key, 51 | sort_value: this.data.sort_value 52 | }).then((res) => { 53 | 54 | let products = []; 55 | if (loadMore == true) { 56 | products = this.data.products; 57 | } else { 58 | //重置使用页面回到顶部 59 | this.setData({ 60 | products: [], 61 | }) 62 | products = []; 63 | } 64 | 65 | let newPorducts = products.concat(res.products); 66 | this.setData({ 67 | products: newPorducts, 68 | paged: res.paged, 69 | requestLoading: false 70 | }) 71 | wx.hideLoading(); 72 | }); 73 | }, 74 | 75 | /** 76 | * 生命周期函数--监听页面加载 77 | */ 78 | onLoad: function (options) { 79 | this.setData({ 80 | category: options.category || '', 81 | keyword: options.keyword || '' 82 | }) 83 | this.getPorducts(); 84 | }, 85 | 86 | /** 87 | * 生命周期函数--监听页面初次渲染完成 88 | */ 89 | onReady: function () { 90 | 91 | }, 92 | 93 | /** 94 | * 生命周期函数--监听页面显示 95 | */ 96 | onShow: function () { 97 | 98 | }, 99 | 100 | /** 101 | * 生命周期函数--监听页面隐藏 102 | */ 103 | onHide: function () { 104 | 105 | }, 106 | 107 | /** 108 | * 生命周期函数--监听页面卸载 109 | */ 110 | onUnload: function () { 111 | 112 | }, 113 | 114 | /** 115 | * 页面相关事件处理函数--监听用户下拉动作 116 | */ 117 | onPullDownRefresh: function () { 118 | 119 | }, 120 | 121 | /** 122 | * 页面上拉触底事件的处理函数 123 | */ 124 | onReachBottom: function () { 125 | 126 | if (this.data.paged.more === 1) { 127 | this.setData({ 128 | 'paged.page': parseInt(this.data.paged.page) + 1 129 | }) 130 | this.getPorducts(true); 131 | } 132 | 133 | 134 | }, 135 | 136 | /** 137 | * 用户点击右上角分享 138 | */ 139 | onShareAppMessage: function () { 140 | 141 | } 142 | }) -------------------------------------------------------------------------------- /pages/goods/detail/detail.wxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | {{goods.name}} 10 | ¥{{goods.current_price}} 11 | 12 | 13 | 14 | 请选择规格数量 15 | 16 | 17 | 18 | 19 | {{item.name}} 20 | 21 | {{vitem.attr_name}} 22 | 23 | 24 | 25 | 购买数量 26 | 27 | - 28 | 29 | + 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 商品详情 39 | 40 | 41 |