此实例为小程序前端程序,后端api是php实现的,源码在这里: http://www.haolizi.net/example/view_14984.html

微信小程序商城源码最新更新2018-4-14

微信小程序商城源码最新更新2018-4-14

微信小程序商城源码最新更新2018-4-14

微信小程序商城源码最新更新2018-4-14

微信小程序商城源码最新更新2018-4-14

var qcloud = require('../../vendor/wafer2-client-sdk/index')var config = require('../../config')var util = require('../../utils/util.js')const App = getApp()Page({ data: { userInfo: {}, items: [ { icon: '../../assets/images/iconfont-order.png', text: '我的订单', path: '/pages/order/list/index' }, { icon: '../../assets/images/iconfont-addr.png', text: '收货地址', path: '/pages/address/list/index' }, { icon: '../../assets/images/iconfont-kefu.png', text: '联系客服', path: '15219941518', } ], settings: [ { icon: '../../assets/images/iconfont-clear.png', text: '清除缓存', path: '0.0KB' }, { icon: '../../assets/images/iconfont-about.png', text: '关于我们', path: '/pages/about/about' } ] }, onLoad:function(options){ const openId = wx.getStorageSync('session3rd') if(openId){ //如果登录 this.getUserInfo() this.getStorageInfo() }else{ this.login() } }, login:function(){ wx.redirectTo({ url:"/pages/login/login" }); }, getUserInfo:function() { var that=this console.log(App.globalData.userInfo); if (App.globalData.userInfo) { this.setData({ userInfo:App.globalData.userInfo }) return }else{ wx.getUserInfo({ success: function(res) { var userInfo = res.userInfo that.setData({ userInfo: userInfo }) } }) } }, getStorageInfo:function() { var that=this wx.getStorageInfo({ success: function(res) { that.setData({ 'settings[0].path': `${res.currentSize}KB` }) } }) }, navigateTo:function(e) { const index = e.currentTarget.dataset.index const path = e.currentTarget.dataset.path switch(index) { case 2: wx.makePhoneCall({ phoneNumber: path }) break default: wx.navigateTo({ url:path }) } }, bindtap:function(e) { const index = e.currentTarget.dataset.index const path = e.currentTarget.dataset.path switch(index) { case 0: wx.showModal({ title: '友情提示', content: '确定要清除缓存吗?', success: function(res) { if (res.confirm) { wx.clearStorage() } else if (res.cancel) { console.log('用户点击取消') } } }) break default: wx.navigateTo({ url:path }) } }, logout:function() { var that=this wx.showModal({ title: '友情提示', content: '确定要登出吗?', success: function(res) { if (res.confirm) { that.signOut() } else if (res.cancel) { console.log('用户点击取消') } } }) }, signOut:function() { wx.request({ url:config.service.signOutUrl, data:{session3rd:'session3rd'}, success:function(res){ if (res.meta.code == 0) { wx.removeStorageSync('session3rd') wx.redirectTo({ url:"/pages/login/login" }) } } }) },})