Authored by 肖亚东

1、消息和收藏请求修改 2、地址管理部分接口联调 — review by 李其昌

... ... @@ -46,8 +46,8 @@ Page({
wx.hideLoading();
})
.then(data => {
if (data && data.code == 200 && data.data) {
let messageTypeList = data.data;
if (data) {
let messageTypeList = data;
const list = messageTypeList.map(item => {
const unReadCount = item.unReadCount > 100 ? '99+' : item.unReadCount;
item.unReadCount = unReadCount;
... ... @@ -91,8 +91,8 @@ Page({
wx.hideLoading();
})
.then(data => {
if (data && data.code == 200 && data.data.list) {
let msgList = data.data.list;
if (data) {
let msgList = data.list;
const list = msgList.map(item => {
let createTime = formatTimeByDefined(item.createTime, 'Y.M.D h:m:s');
item.createTime = createTime;
... ...
... ... @@ -59,8 +59,8 @@ Page({
wx.hideLoading();
})
.then(data => {
if (data && data.code == 200 && data.data.list) {
let msgList = data.data.list;
if (data) {
let msgList = data.list;
const list = msgList.map(item => {
let createTime = formatTimeByDefined(item.createTime, 'Y.M.D h:m:s');
item.createTime = createTime;
... ...
... ... @@ -16,7 +16,8 @@ export default class MessageService extends BaseService {
).then((data) => {
return data;
}).catch((error) => {
return error;
// 这里请抛出异常,不要return
throw error;
})
}
... ... @@ -32,7 +33,8 @@ export default class MessageService extends BaseService {
).then((data) => {
return data;
}).catch((error) => {
return error;
// 这里请抛出异常,不要return
throw error;
})
}
}
... ...
... ... @@ -3,6 +3,8 @@
// import { API_HOST, SERVICE_HOST } from '../../../libs/config';
// import { GET, POST } from '../../../libs/request';
// import Promise from '../../../vendors/es6-promise';
import AddressService from '../addressService.js'
import user from '../../../../utils/user';
var modeEdit = "modeEdit";
var modeSelect = "modeSelect";
... ... @@ -18,6 +20,7 @@ Page({
* 页面的初始数据
*/
data: {
addressTitle: '',
editeAddressPage: {
currentEditMode: modeAdd,
_consignee: "",
... ... @@ -26,6 +29,7 @@ Page({
_area_code: 0,
_address: "",
_id: "",
_is_default: "N",
},
originAddressList: [],
},
... ... @@ -35,12 +39,19 @@ Page({
onLoad: function (options) {
// new app.WeToast;
let timestamp = options.timestamp;
let value = getYHStorageSync(timestamp, 'addressEditer');
let value = user.getYHStorageSync(timestamp, 'addressEditer');
let addressTitle = (value && (value.currentEditMode === 'modeEdit')) ? '编辑地址' : '添加地址';
let address = value && value._address ? value._address : '';
let originAddressList = address ? address.split(" ") : [];
console.log('====================================');
console.log(value);
console.log('====================================');
this.setData({
editeAddressPage: value,
originAddressList,
addressTitle,
});
try {
wx.setStorageSync(timestamp, null);//清除内存
... ... @@ -114,6 +125,29 @@ Page({
}
},
defaultButtonTapped: function(e) {
let id = e.currentTarget.dataset.id;
let params = {
id: id,
uid: '500031152',
debug: 'XYZ'
};
let that = this;
let api = new AddressService().yohoApi();
api.fetchAddressDefault(params)
.then(data => {
let editeAddressPage = that.data.editeAddressPage;
editeAddressPage._is_default = 'Y';
that.setData({
editeAddressPage
});
})
.catch(error => {
console.log(error);
})
},
onDeleteButtonTapped: function () {
let that = this;
wx.showModal({
... ...
... ... @@ -3,7 +3,7 @@
</addressPicker>
<view class="addressEditerContainer">
<text class='address-title'>添加地址</text>
<text class='address-title'>{{addressTitle}}</text>
<view class="page-container">
<view class="cell-container cell-bottom-border">
... ... @@ -25,13 +25,15 @@
</view>
</view>
<view class='left' catchtap="setDefaultButtonTapped" data-id="{{item.address_id}}">
<image src='{{item.is_default=="Y"?"../../../../assets/images/default-select@3x.png":"../../../../assets/images/default-normal@3x.png"}}' class='select-image'></image>
<text class='opt-text'>设为默认地址</text>
<view class='operation'>
<view class="left" catchtap="defaultButtonTapped" data-id="{{editeAddressPage._id}}">
<image src='{{editeAddressPage._is_default=="Y"?"../../../../assets/images/default-select@3x.png":"../../../../assets/images/default-normal@3x.png"}}' class='select-image'></image>
<text class='opt-text'>设为默认地址</text>
</view>
<view hidden="{{editeAddressPage.currentEditMode == 'modeAdd'}}" class='delete-btn' catchtap="onDeleteButtonTapped" data-id="{{editeAddressPage.address_id}}">删除地址</view>
</view>
<button type="primary" class="submit-btn" size="default" catchtap="onSubmitButtonTapped">确定</button>
<button hidden="{{editeAddressPage.currentEditMode == 'modeAdd'}}" type="primary" class="delete-btn" size="default" catchtap="onDeleteButtonTapped"> 删除地址 </button>
</view>
<!-- <import src="../../../vendors/toast/wetoast.wxml"/>
<template is="wetoast" data="{{...__wetoast__}}"/> -->
... ...
... ... @@ -60,23 +60,36 @@
z-index:900;
}
.addressEditerContainer .left {
.addressEditerContainer .operation {
margin-top: 30rpx;
margin-left: 40rpx;
margin-right: 40rpx;
display: flex;
align-items: center;
justify-content: space-between;
}
.addressEditerContainer .operation .left {
display: flex;
align-items: center;
}
.addressEditerContainer .operation .select-image {
width: 34rpx;
height: 34rpx;
}
.addressEditerContainer .left .opt-text {
.addressEditerContainer .operation .opt-text {
margin-left: 20rpx;
font-family: PingFang-SC-Regular;
font-size: 26rpx;
color: black;
}
.addressEditerContainer .left .select-image {
margin-left: 40rpx;
width: 34rpx;
height: 34rpx;
.addressEditerContainer .operation .delete-btn {
color: #CD001A;
font-family: PingFang-SC-Regular;
font-size: 26rpx;
}
.addressEditerContainer .submit-btn {
... ... @@ -93,15 +106,7 @@
background-color: #002B47;
font-size: 32rpx;
font-family: PingFang-SC-Regular;
}
.addressEditerContainer .delete-btn {
margin-left: 30rpx;
margin-right: 30rpx;
margin-top: -30rpx;
height: 44px;
background: #B0B0B0;
border-radius: 4px;
border-radius: 0;
}
.addressEditerContainer .picker-view {
... ...
import AddressService from './AddressService.js'
import AddressService from './addressService.js'
// import {
// logEvent,
... ... @@ -28,7 +28,7 @@ Page({
current_page_name: 'addressManager',
current_page_param: '',
//data for edit page
//data for edit page
editeAddressPage: {
currentEditMode: modeAdd,
_consignee: "",
... ... @@ -36,7 +36,9 @@ Page({
_detailAddress: "",
_area_code: 0,
_address: "",
_id: "",},
_id: "",
_is_default: "N",
},
currentSelectedIndex: -1,
addType: 'none' // normal or wechat
... ... @@ -216,6 +218,7 @@ Page({
let area_code = e.currentTarget.dataset.area_code;
let address = e.currentTarget.dataset.address;
let detailAddress = e.currentTarget.dataset.detail_address;
let is_default = e.currentTarget.dataset.is_default;
let newEditeAddressPage = Object.assign(this.data.editeAddressPage, {
_consignee: consignee,
_mobile: mobile,
... ... @@ -224,7 +227,9 @@ Page({
_detailAddress: detailAddress,
_page_name: '编辑地址',
_id: id,
currentEditMode: modeEdit,});
currentEditMode: modeEdit,
_is_default: is_default,
});
var timestamp = Date.parse(new Date());
try {
... ... @@ -277,7 +282,6 @@ Page({
},
addButtonTapped: function() {
console.log('===============');
// if (app.globalData.userInfo.uid == 0 || app.globalData.userInfo.uid == undefined){
// //未登录状态
... ... @@ -305,7 +309,7 @@ Page({
// })
// return;
// }
console.log('===============');
let newEditeAddressPage = Object.assign(this.data.editeAddressPage, {
currentEditMode: modeAdd,
_consignee: "",
... ... @@ -418,10 +422,9 @@ Page({
let api = new AddressService().yohoApi();
api.fetchAddressList(params)
.then(json => {
console.log(json)
if (json && json.code && json.code == 200) {
this.data.items = json.data
.then(data => {
if (data) {
this.data.items = data
let currentSelectedIndex = -1;
this.data.items.map((item, index) => {
if (this.data.address_id == item.address_id) {
... ...
... ... @@ -12,7 +12,7 @@
<view class="name">{{item.consignee}}</view>
<view class="tel">{{item.mobile}}</view>
<view class="default" wx:if="{{item.is_default=='Y'}}">默认</view>
<view catchtap="editButtonTapped" class="edit" data-id="{{item.address_id}}" data-consignee="{{item.consignee}}" data-mobile="{{item.mobile}}" data-area_code="{{item.area_code}}" data-address="{{item.area}}" data-detail_address="{{item.address}}">编辑</view>
<view catchtap="editButtonTapped" class="edit" data-id="{{item.address_id}}" data-consignee="{{item.consignee}}" data-mobile="{{item.mobile}}" data-area_code="{{item.area_code}}" data-address="{{item.area}}" data-detail_address="{{item.address}}" data-is_default="{{item.is_default}}">编辑</view>
</view>
<view class="address-info">{{item.area + ' ' + item.address}}</view>
<view class='separator'></view>
... ...
import BaseService from '../../../libs/services/baseService.js';
const UFO_ADDRESS_LIST = 'app.address.gethidden';
const UFO_ADDRESS_SET_DEFAULT = 'app.address.setdefault';
export default class AddressService extends BaseService {
async fetchAddressList(params, complete) {
... ... @@ -15,7 +16,25 @@ export default class AddressService extends BaseService {
).then((data) => {
return data;
}).catch((error) => {
return error;
// 这里请抛出异常,不要return
throw error;
})
}
async fetchAddressDefault(params, complete) {
return await this.GET(
{
...params,
method: UFO_ADDRESS_SET_DEFAULT
},
{
complete
}
).then((data) => {
return data;
}).catch((error) => {
// 这里请抛出异常,不要return
throw error;
})
}
}
\ No newline at end of file
... ...
... ... @@ -49,8 +49,8 @@ Page({
wx.hideLoading();
})
.then(data => {
if (data && data.code == 200 && data.data.product_list) {
let list = data.data.product_list;
if (data) {
let list = data.product_list;
collectionInfo.isLoading = false;
collectionInfo.collectionList = collectionInfo.collectionList.concat(list);
let hasMore = collectionInfo.currentPage < data.totalPage;
... ...
... ... @@ -15,7 +15,8 @@ export default class CollectionService extends BaseService {
).then((data) => {
return data;
}).catch((error) => {
return error;
// 这里请抛出异常,不要return
throw error;
})
}
}
\ No newline at end of file
... ...