Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

小程序前端界面调整及部分功能实现,java后端添加阿里云对象存储 #31

Merged
merged 6 commits into from
Jul 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions litemall-os-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
<version>5.4.4</version>
</dependency>

<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>2.5.0</version>
</dependency>

</dependencies>

Expand Down
Original file line number Diff line number Diff line change
@@ -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<Path> 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;
}
}
6 changes: 6 additions & 0 deletions litemall-os-api/src/main/resources/aliyun.properties
Original file line number Diff line number Diff line change
@@ -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"
22 changes: 12 additions & 10 deletions litemall-wx/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "个人"
}
]
Expand Down
49 changes: 49 additions & 0 deletions litemall-wx/pages/about/index.js
Original file line number Diff line number Diff line change
@@ -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();
}
})
1 change: 1 addition & 0 deletions litemall-wx/pages/about/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
43 changes: 43 additions & 0 deletions litemall-wx/pages/about/index.wxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<view class="container">

<view class="about-item">

<view class="item-left">
<label>项目名称: </label>
<text>{{shopInfo.name}}</text>
</view>

</view>

<view class="about-item">
<view class="item-left">
<label>项目地址: </label>
<text>{{shopInfo.address}}</text>
</view>

<view class="item-right" bindtap="showLocation">
<image src="/static/images/ico-addr.png" class="right-icon"></image>
</view>
</view>

<view class="about-item">
<view class="item-left">
<label>电话号码: </label>
<text>{{shopInfo.linkPhone}}</text>
</view>
<view class="item-right" bindtap="callPhone">
<image src="/static/images/telephone.png" class="right-icon"></image>
</view>
</view>

<view class="about-item">
<view class="item-left">
<label>litemall交流群: </label>
<text>{{shopInfo.qqNumber}}</text>
</view>
<view class="item-right">
<image src="/static/images/mobile.png" class="right-icon"></image>
</view>
</view>

</view>
44 changes: 44 additions & 0 deletions litemall-wx/pages/about/index.wxss
Original file line number Diff line number Diff line change
@@ -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;
}
Loading