diff --git a/litemall-os-api/pom.xml b/litemall-os-api/pom.xml index 529eaac7..10c70c57 100644 --- a/litemall-os-api/pom.xml +++ b/litemall-os-api/pom.xml @@ -28,6 +28,11 @@ 5.4.4 + + com.aliyun.oss + aliyun-sdk-oss + 2.5.0 + diff --git a/litemall-os-api/src/main/java/org/linlinjava/litemall/os/service/AliyunOsService.java b/litemall-os-api/src/main/java/org/linlinjava/litemall/os/service/AliyunOsService.java new file mode 100644 index 00000000..f2045092 --- /dev/null +++ b/litemall-os-api/src/main/java/org/linlinjava/litemall/os/service/AliyunOsService.java @@ -0,0 +1,111 @@ +package org.linlinjava.litemall.os.service; + +import com.aliyun.oss.OSSClient; +import com.aliyun.oss.model.ObjectMetadata; +import com.aliyun.oss.model.PutObjectRequest; +import com.aliyun.oss.model.PutObjectResult; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.PropertySource; +import org.springframework.core.io.Resource; +import org.springframework.core.io.UrlResource; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.file.Path; +import java.util.stream.Stream; + +/** + * @author Yogeek + * @date 2018/7/16 16:10 + * @decrpt 阿里云对象存储服务 + */ +@PropertySource(value = "classpath:aliyun.properties") +@Service("aos") +public class AliyunOsService implements ObjectStorageService { + + @Value("${aliyun.os.ENDPOINT}") + private String ENDPOINT; + @Value("${aliyun.os.ACCESS_KEY_ID}") + private String ACCESS_KEY_ID; + @Value("${aliyun.os.ACCESS_KEY_SECRET}") + private String ACCESS_KEY_SECRET; + @Value("${aliyun.os.BUCKET_NAME}") + private String BUCKET_NAME; +// @Value("${aliyun.os.FOLDER}") +// private String FOLDER; + + /** + * 获取阿里云OSS客户端对象 + * + * @return ossClient + */ + private OSSClient getOSSClient(){ + return new OSSClient(ENDPOINT,ACCESS_KEY_ID, ACCESS_KEY_SECRET); + } + + private String getBaseUrl() { + return "https://" + BUCKET_NAME + "." + ENDPOINT + "/" ; + } + + /** + * 阿里云OSS对象存储简单上传实现 + */ + @Override + public void store(MultipartFile file, String keyName) { + try { + // 简单文件上传, 最大支持 5 GB, 适用于小文件上传, 建议 20M以下的文件使用该接口 + ObjectMetadata objectMetadata = new ObjectMetadata(); + objectMetadata.setContentLength(file.getSize()); + objectMetadata.setContentType(file.getContentType()); + // 对象键(Key)是对象在存储桶中的唯一标识。 + PutObjectRequest putObjectRequest = new PutObjectRequest(BUCKET_NAME, keyName, file.getInputStream(), objectMetadata); + PutObjectResult putObjectResult = getOSSClient().putObject(putObjectRequest); + } catch (Exception ex) { + ex.printStackTrace(); + } + + } + + @Override + public Stream loadAll() { + return null; + } + + @Override + public Path load(String keyName) { + return null; + } + + @Override + public Resource loadAsResource(String keyName) { + try { + URL url = new URL(getBaseUrl() + keyName); + Resource resource = new UrlResource(url); + if (resource.exists() || resource.isReadable()) { + return resource; + } else { + return null; + } + } catch (MalformedURLException e) { + e.printStackTrace(); + return null; + } + } + + @Override + public void delete(String keyName) { + try { + getOSSClient().deleteObject(BUCKET_NAME, keyName); + }catch (Exception e){ + e.printStackTrace(); + } + + } + + @Override + public String generateUrl(String keyName) { + return getBaseUrl() + keyName; + } +} diff --git a/litemall-os-api/src/main/resources/aliyun.properties b/litemall-os-api/src/main/resources/aliyun.properties new file mode 100644 index 00000000..18eebadb --- /dev/null +++ b/litemall-os-api/src/main/resources/aliyun.properties @@ -0,0 +1,6 @@ +# ƶ洢Ϣ +aliyun.os.ENDPOINT=oss-cn-shenzhen.aliyuncs.com +aliyun.os.ACCESS_KEY_ID= +aliyun.os.ACCESS_KEY_SECRET= +aliyun.os.BUCKET_NAME= +#aliyun.os.FOLDER="xxxxxx" \ No newline at end of file diff --git a/litemall-wx/app.json b/litemall-wx/app.json index e063d598..59b59c90 100644 --- a/litemall-wx/app.json +++ b/litemall-wx/app.json @@ -31,43 +31,45 @@ "pages/shopping/checkout/checkout", "pages/shopping/address/address", "pages/shopping/addressAdd/addressAdd", - "pages/goods/goods" + "pages/goods/goods", + "pages/about/index" ], "window": { + "navigationBarTitleText": "litemall小程序商城", + "navigationBarTextStyle": "#FFFFFF", + "navigationBarBackgroundColor": "#696969", + "backgroundColor": "#FFFFFF", "backgroundTextStyle": "dark", - "navigationBarBackgroundColor": "#fff", - "navigationBarTitleText": "仿网易严选", - "navigationBarTextStyle": "black", - "enablePullDownRefresh": true + "enablePullDownRefresh": false }, "tabBar": { "backgroundColor": "#fafafa", "borderStyle": "white", - "selectedColor": "#b4282d", + "selectedColor": "#AB956D", "color": "#666", "list": [ { "pagePath": "pages/index/index", "iconPath": "static/images/ic_menu_choice_nor.png", - "selectedIconPath": "static/images/ic_menu_choice_pressed.png", + "selectedIconPath": "static/images/home@selected.png", "text": "首页" }, { "pagePath": "pages/catalog/catalog", "iconPath": "static/images/ic_menu_sort_nor.png", - "selectedIconPath": "static/images/ic_menu_sort_pressed.png", + "selectedIconPath": "static/images/category@selected.png", "text": "分类" }, { "pagePath": "pages/cart/cart", "iconPath": "static/images/ic_menu_shoping_nor.png", - "selectedIconPath": "static/images/ic_menu_shoping_pressed.png", + "selectedIconPath": "static/images/cart@selected.png", "text": "购物车" }, { "pagePath": "pages/ucenter/index/index", "iconPath": "static/images/ic_menu_me_nor.png", - "selectedIconPath": "static/images/ic_menu_me_pressed.png", + "selectedIconPath": "static/images/my@selected.png", "text": "个人" } ] diff --git a/litemall-wx/pages/about/index.js b/litemall-wx/pages/about/index.js new file mode 100644 index 00000000..e246322c --- /dev/null +++ b/litemall-wx/pages/about/index.js @@ -0,0 +1,49 @@ +// index.js +var app = getApp() +var util = require("../../utils/util.js"); + + +var api = require("../../config/api.js"); +Page({ + + /** + * 页面的初始数据 + */ + data: { + load_statue: true, + shopInfo: { + name: 'litemall', + address: 'https://github.com/linlinjava/litemall', + latitude: 22.60, + longitude: 116.87, + linkPhone: '0755-xxxx-xxxx', + qqNumber: '738696120' + }, + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + + }, + + showLocation: function (e) { + var that = this + wx.openLocation({ + latitude: that.data.shopInfo.latitude, + longitude: that.data.shopInfo.longitude, + name: that.data.shopInfo.name, + address: that.data.shopInfo.address, + }) + }, + callPhone: function (e) { + var that = this + wx.makePhoneCall({ + phoneNumber: that.data.shopInfo.linkPhone, + }) + }, + reLoad: function (e) { + this.loadShopInfo(); + } +}) \ No newline at end of file diff --git a/litemall-wx/pages/about/index.json b/litemall-wx/pages/about/index.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/litemall-wx/pages/about/index.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/litemall-wx/pages/about/index.wxml b/litemall-wx/pages/about/index.wxml new file mode 100644 index 00000000..37892c05 --- /dev/null +++ b/litemall-wx/pages/about/index.wxml @@ -0,0 +1,43 @@ + + + + + + + {{shopInfo.name}} + + + + + + + + {{shopInfo.address}} + + + + + + + + + + + {{shopInfo.linkPhone}} + + + + + + + + + + {{shopInfo.qqNumber}} + + + + + + + \ No newline at end of file diff --git a/litemall-wx/pages/about/index.wxss b/litemall-wx/pages/about/index.wxss new file mode 100644 index 00000000..1ea5b4e0 --- /dev/null +++ b/litemall-wx/pages/about/index.wxss @@ -0,0 +1,44 @@ +/* index.wxss */ + +page{ + height: 100%; + background-color: #F2f2f2; +} +.page-view{ + height: 100%; +} +.banner-image{ + width: 100%; + height: 350rpx; + background: #ee1; + margin-bottom: 30rpx; + border-bottom: solid #f2f2f2 0.5dp; +} + +.about-item{ + background: white; + border-top: solid #f2f2f2 0.5rpx; + border-bottom: solid #f2f2f2 0.5rpx; + width: 100%; + height: 100rpx; + display: flex; + flex-direction: row; + justify-content: space-between; +} + +.item-left{ + font-size: 32rpx; + margin-left: 15rpx; + margin-top: auto; + margin-bottom: auto; +} +.item-right{ + + margin-right: 15rpx; + margin-top: auto; + margin-bottom: auto; +} +.right-icon{ + width: 40rpx; + height: 40rpx; +} \ No newline at end of file diff --git a/litemall-wx/pages/goods/goods.js b/litemall-wx/pages/goods/goods.js index e4fa61ce..8db99aad 100644 --- a/litemall-wx/pages/goods/goods.js +++ b/litemall-wx/pages/goods/goods.js @@ -42,7 +42,7 @@ Page({ // 这里检测一下 let _productPrice = res.data.productList[0].price; let _goodsPrice = res.data.info.retailPrice; - if (_productPrice != _goodsPrice){ + if (_productPrice != _goodsPrice) { console.error('商品数量价格和货品不一致'); } @@ -206,21 +206,21 @@ Page({ } let checkedProduct = checkedProductArray[0]; - if (checkedProduct.number > 0){ + if (checkedProduct.number > 0) { this.setData({ checkedSpecPrice: checkedProduct.price, soldout: false }); } - else{ + else { this.setData({ checkedSpecPrice: this.data.goods.retailPrice, soldout: true - }); + }); } - + } - else{ + else { this.setData({ checkedSpecText: '规格数量选择', checkedSpecPrice: this.data.goods.retailPrice, @@ -276,28 +276,33 @@ Page({ }); } }, - closeAttrOrCollect: function () { + closeAttr: function () { + this.setData({ + openAttr: false, + }); + }, + addCollectOrNot: function () { let that = this; - if (this.data.openAttr) { - this.setData({ - openAttr: false, - }); - if (that.data.userHasCollect == 1) { - that.setData({ - collectBackImage: that.data.hasCollectImage - }); - } else { - that.setData({ - collectBackImage: that.data.noCollectImage - }); - } - } else { + // if (this.data.openAttr) { + // this.setData({ + // openAttr: false, + // }); + // if (that.data.userHasCollect == 1) { + // that.setData({ + // collectBackImage: that.data.hasCollectImage + // }); + // } else { + // that.setData({ + // collectBackImage: that.data.noCollectImage + // }); + // } + // } else { //添加或是取消收藏 util.request(api.CollectAddOrDelete, { type: 0, valueId: this.data.id }, "POST") .then(function (res) { let _res = res; if (_res.errno == 0) { - if ( _res.data.type == 'add') { + if (_res.data.type == 'add') { that.setData({ collectBackImage: that.data.hasCollectImage }); @@ -316,7 +321,6 @@ Page({ } }); - } }, openCartPage: function () { @@ -394,7 +398,7 @@ Page({ //打开规格选择窗口 this.setData({ openAttr: !this.data.openAttr, - collectBackImage: '/static/images/detail_back.png' + // collectBackImage: '/static/images/detail_back.png' }); } else { diff --git a/litemall-wx/pages/goods/goods.wxml b/litemall-wx/pages/goods/goods.wxml index 69728868..940bad35 100644 --- a/litemall-wx/pages/goods/goods.wxml +++ b/litemall-wx/pages/goods/goods.wxml @@ -1,112 +1,117 @@ - - - - - - - - - 30天无忧退货 - 48小时快速退款 - 满88元免邮费 - - - - {{goods.name}} - {{goods.goodsBrief}} - ¥{{checkedSpecPrice}} - - - {{brand.name}} - - - - - - {{checkedSpecText}} - - - - - - 评价({{comment.count > 999 ? '999+' : comment.count}}) - 查看全部 + + + + + + + + 30天无忧退货 + 48小时快速退款 + 满88元免邮费 + + + + {{goods.name}} + {{goods.goodsBrief}} + ¥{{checkedSpecPrice}} + + + {{brand.name}} - - - - - - {{item.nickname}} - - {{item.addTime}} - - - {{item.content}} - - - + + + + {{checkedSpecText}} + + + + + + 评价({{comment.count > 999 ? '999+' : comment.count}}) + 查看全部 + + + + + + + + {{item.nickname}} + {{item.addTime}} - - - - 商品参数 - - - {{item.attribute}} - {{item.value}} + + {{item.content}} - - - - - -