|
@@ -6,19 +6,84 @@ Component({
|
|
|
properties: {
|
|
|
item_data: {
|
|
|
type:Object
|
|
|
+ },
|
|
|
+ summery:{
|
|
|
+ type:Array
|
|
|
+ },
|
|
|
+ special_datas:{
|
|
|
+ type:Object,
|
|
|
+ value:{}
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- ready(){
|
|
|
- // console.log(this.properties.item_data);
|
|
|
- },
|
|
|
+ ready() {
|
|
|
+ if (!(this.properties.special_datas).hasOwnProperty('fcodes')){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const fcodes = this.properties.special_datas.fcodes;
|
|
|
+ const goods_id = this.properties.item_data.data;
|
|
|
+ const summery = this.properties.summery;
|
|
|
+ let fcode = {};
|
|
|
+ for (let item of summery) {
|
|
|
+ if (item.goods_id == goods_id){
|
|
|
+ this.setData({
|
|
|
+ goods:item
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (let item of fcodes){
|
|
|
+ if (item.goods_id == goods_id) {
|
|
|
+ fcode = item;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fcode.usable_time = (function(time){
|
|
|
+ let date = new Date(time * 1000);
|
|
|
+ let year = date.getFullYear();
|
|
|
+ let month = date.getMonth() + 1;
|
|
|
+ let day = date.getDate();
|
|
|
+ return `${year}.${month}.${day}`;
|
|
|
+ })(fcode.usable_time);
|
|
|
|
|
|
+ fcode.state = (function(state){
|
|
|
+ let bgColor = '';
|
|
|
+ let title = '';
|
|
|
+ switch (state) {
|
|
|
+ case 0:
|
|
|
+ bgColor = "#ffa82d";
|
|
|
+ title = "可使用";
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ bgColor = "#bfbfbf";
|
|
|
+ title = "已用完";
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ bgColor = "#bfbfbf";
|
|
|
+ title = "已过期";
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ bgColor = "#7e7e7e";
|
|
|
+ title = '已锁定';
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ bgColor: bgColor,
|
|
|
+ title: title
|
|
|
+ }
|
|
|
+ })(fcode.state);
|
|
|
+ this.setData({
|
|
|
+ fcode:fcode
|
|
|
+ })
|
|
|
+ },
|
|
|
|
|
|
/**
|
|
|
* 组件的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
- imgShow:false
|
|
|
+ imgShow:false,
|
|
|
+ goods: {},
|
|
|
+ fcode: {}
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -26,9 +91,9 @@ Component({
|
|
|
*/
|
|
|
methods: {
|
|
|
navigator(e){
|
|
|
- const type = e.target.dataset.type;
|
|
|
- const target_data = e.target.dataset.target;
|
|
|
- const title = e.target.dataset.title;
|
|
|
+ const type = e.target.dataset.type || e.currentTarget.dataset.type;
|
|
|
+ const target_data = e.target.dataset.target || e.currentTarget.dataset.target;
|
|
|
+ const title = e.target.dataset.title || e.currentTarget.dataset.title;
|
|
|
if(!type)return;
|
|
|
switch(type){
|
|
|
case "url":{
|
|
@@ -62,7 +127,6 @@ Component({
|
|
|
}
|
|
|
},
|
|
|
load(e){
|
|
|
-
|
|
|
this.setData({
|
|
|
imgShow:true
|
|
|
});
|