Commit af9b551e8a9f0107c72a0b55715327a034299daf

Authored by yvan.ni
1 parent 9b43128b

预售商品

components/diy_pregoods/diy_pregoods.js 0 → 100644
  1 +var t = getApp(), os = t.globalData.setting,ut = require("../../utils/util.js");
  2 +var regeneratorRuntime = require('../../utils/runtime.js');
  3 +Component({
  4 + properties: {
  5 + // 这里定义了innerText属性,属性值可以在组件使用时指定
  6 + object: {
  7 + type: Object, value: null,
  8 + },
  9 + goods_array: {
  10 + type: Array, value: []
  11 + },
  12 + },
  13 + data: {
  14 + // 这里是一些组件内部数据
  15 + someData: null,
  16 + imghost: os.imghost,
  17 + },
  18 +
  19 + ready: function() {
  20 + var g_id = this.data.object.data;
  21 + this.init(g_id);
  22 + },
  23 +
  24 + methods: {
  25 + // 这里是一个自定义方法
  26 + init: function(g_id) {
  27 + var th = this, app = getApp(), goodsidlist="";
  28 + if(g_id && g_id.length>0){
  29 + //--先把商品ID串起来--
  30 + g_id.forEach(function(val, ind) {
  31 + var item = {};
  32 + goodsidlist+=val.goodsid+",";
  33 + })
  34 + goodsidlist=ut.sub_last(goodsidlist);
  35 + //--调用接口,读取秒杀--
  36 + app.request.promiseGet("/api/weshop/marketing/marketingPresellList/page?store_id="
  37 + +os.stoid+"&goodsidlist="+goodsidlist, {
  38 + data:{is_end:0,timetype:1,isuse:1}
  39 + }).then(res => {
  40 + //如果秒杀的数组为空的时候
  41 + var goodslist=res.data.data;
  42 + //就算是添加的活动已经过期,就要用最新的进行中活动
  43 + if(goodslist && goodslist.length>0) {
  44 + th.set_goods_list(g_id,goodslist);
  45 + }
  46 + });
  47 + }else{
  48 + th.no_gid_set();
  49 + }
  50 + },
  51 +
  52 + //当是默认的情况
  53 + no_gid_set(){
  54 + getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/page",
  55 + {isShowLoading:1,data:{store_id:os.stoid,is_end:0,timetype:1,page:1,pageSize:9 }}
  56 + ).then(res=>{
  57 + if(res.data.code==0 && res.data.data.pageData && res.data.data.pageData.length>0) {
  58 + var goodsidlist=res.data.data.pageData;
  59 + this.set_goods_list(null,goodsidlist);
  60 + }
  61 + });
  62 + },
  63 +
  64 + //就算是添加的活动已经过期,就要用最新的活动
  65 + set_goods_list(g_id,goodslist){
  66 + // 判断火热,预热
  67 + var newTime = ut.gettimestamp(),all_array = [],th=this;
  68 + th.setData({newTime:newTime});
  69 + if(g_id){
  70 + /*--商品队列按照添加的顺序排列--*/
  71 + g_id.forEach(function(val, ind) {
  72 + goodslist.forEach(function (vy,indy) {
  73 + if(val.goodsid==vy.goods_id){ all_array.push(vy); }
  74 + })
  75 + })
  76 + }else{
  77 + all_array=goodslist;
  78 + }
  79 +
  80 + if(all_array.length==0){ all_array=goodslist;}
  81 +
  82 + var arr = new Array();
  83 + //--三个三个一组---
  84 + for(var i=0;i< all_array.length;i+=3){
  85 + arr.push(all_array.slice(i,i+3));
  86 + }
  87 + /*--熏染到前台--*/
  88 + th.setData({goods_array:arr});
  89 + },
  90 +
  91 + //图片失败,默认图片
  92 + bind_bnerr3: function (e) {
  93 + var _errImg = e.target.dataset.errorimg;
  94 + var _errObj = {};
  95 + _errObj[_errImg] = "/public/images/default_goods_image_240.gif";
  96 + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
  97 + },
  98 +
  99 + go_to_skill:function () {
  100 + wx.navigateTo({
  101 + url:"/packageC/pages/presell/list/list"
  102 + });
  103 + }
  104 + },
  105 +
  106 +
  107 +})
0 108 \ No newline at end of file
... ...
components/diy_pregoods/diy_pregoods.json 0 → 100644
  1 +{
  2 + "component": true,
  3 + "usingComponents": {}
  4 +}
0 5 \ No newline at end of file
... ...
components/diy_pregoods/diy_pregoods.wxml 0 → 100644
  1 +<block wx:if="{{goods_array.length>0}}">
  2 + <!--秒杀-->
  3 + <view class='top' bindtap="go_to_skill">
  4 + <view class="flex">
  5 + <view class='t_left'></view>
  6 + <view class='t_ms'>秒杀</view>
  7 + </view>
  8 + <view class='right_k'>
  9 + <image src="{{imghost}}/miniapp/images/icon-arrowdown.png" lazy-load="true"></image>
  10 + </view>
  11 + </view>
  12 +
  13 + <!--商品展示-->
  14 + <swiper class="s_prom" indicator-active-color='red' indicator-dots="false" wx:if="{{object.style==1}}">
  15 + <view class='sp' wx:if="{{object.style==1}}">
  16 + <swiper-item class="s_it" wx:for="{{goods_array}}">
  17 + <block wx:for="{{item}}" wx:for-item="aitem" wx:for-index="aind">
  18 + <navigator url="/pages/goods/goodsInfo/goodsInfo?goods_id={{aitem.goods_id}}" class="s1_gk_a1">
  19 + <view class='one'>
  20 + <view class='sp_top'>
  21 + <view class='po'></view>
  22 + <block wx:if="{{aitem.start_time>newTime}}">
  23 + <view class="rob">
  24 + <span class='s_top_kill' style="background-color: #ffe718;color: #3c3b31;font-weight: bold">即将开始</span>
  25 + </view>
  26 + </block>
  27 +
  28 + <block wx:if="{{aitem.end_time<=newTime}}">
  29 + <view class="rob">
  30 + <span class='s_top_kill gray'>活动已结束</span>
  31 + </view>
  32 + </block>
  33 + <block wx:else>
  34 + <block wx:if="{{aitem.start_time<newTime && aitem.goods_num>aitem.buy_num}}">
  35 + <view class="rob">
  36 + <span class='s_top_kill'>火热进行</span>
  37 + </view>
  38 + </block>
  39 + <block wx:if="{{aitem.goods_num<=aitem.buy_num}}">
  40 + <view class="rob">
  41 + <span class='s_top_kill gray'>已抢光</span>
  42 + </view>
  43 + </block>
  44 + </block>
  45 +
  46 +
  47 +
  48 + <view class='clear'></view>
  49 +
  50 + <view class='s_img'>
  51 + <image src="{{imghost+aitem.original_img}}" data-errorimg="goods_array[{{index}}][{{aind}}].original_img" binderror="bind_bnerr3"></image>
  52 + </view>
  53 +
  54 + <view class='s_foot_kill'>
  55 + <text>{{aitem.djs.day}}天</text>
  56 + <text>{{aitem.djs.hou}}时</text>
  57 + <text>{{aitem.djs.min}}分</text>
  58 + <text>{{aitem.djs.sec}}秒</text>
  59 + </view>
  60 + <view class='clear'></view>
  61 +
  62 + </view>
  63 +
  64 + <view class='sp_wz'>
  65 + <view class='sp_wzi'>{{aitem.title}}</view>
  66 + <view class='sp_jg'>¥{{aitem.price}}</view>
  67 + <view class='sp_jgx'>¥{{aitem.market_price}}</view>
  68 + </view>
  69 +
  70 + </view>
  71 + </navigator>
  72 + </block>
  73 + </swiper-item>
  74 + </view>
  75 + </swiper>
  76 +
  77 + <view class="sp2" wx:if="{{object.style==2}}">
  78 + <block wx:for="{{goods_array}}">
  79 + <block wx:for="{{item}}" wx:for-item="aitem" wx:for-index="aind">
  80 + <navigator url="/pages/goods/goodsInfo/goodsInfo?goods_id={{aitem.goods_id}}" class="s1_gk_a1">
  81 + <view class='one1'>
  82 +
  83 + <view class="o1_img">
  84 + <image src="{{imghost+aitem.original_img}}" data-errorimg="goods_array[{{index}}][{{aind}}].original_img" binderror="bind_bnerr3"></image>
  85 + </view>
  86 +
  87 + <view class="o1_right">
  88 + <view class="sp_wzi">{{aitem.title}}</view>
  89 + <view class="o1_sj_kill">
  90 + <text>{{aitem.djs.day}}</text> 天
  91 + <text>{{aitem.djs.hou}}</text> :
  92 + <text>{{aitem.djs.min}}</text> :
  93 + <text>{{aitem.djs.sec}}</text>
  94 +
  95 + </view>
  96 + <view class="money">
  97 + <view class='sp_jg'>¥{{aitem.price}}</view>
  98 + <view class='sp_jgx'>¥{{aitem.market_price}}</view>
  99 + </view>
  100 + <block wx:if="{{aitem.start_time>newTime}}">
  101 + <view class="rob">
  102 + <view class="wo" style="background-color: #adadad">正在预热</view>
  103 + </view>
  104 + </block>
  105 +
  106 + <block wx:if="{{aitem.end_time<newTime}}">
  107 + <view class="rob">
  108 + <view class="wo" style="background-color: #adadad">已结束</view>
  109 + </view>
  110 + </block>
  111 + <block wx:else>
  112 + <block wx:if="{{aitem.start_time<newTime && aitem.goods_num>aitem.buy_num}}">
  113 + <view class="rob">
  114 + <view class="wo">我要抢</view>
  115 + </view>
  116 + </block>
  117 +
  118 + <block wx:if="{{aitem.goods_num<=aitem.buy_num}}">
  119 + <view class="rob">
  120 + <view class="wo" style="background-color: #adadad">已抢光</view>
  121 + </view>
  122 + </block>
  123 + </block>
  124 +
  125 +
  126 + </view>
  127 + </view>
  128 + </navigator>
  129 + </block>
  130 + </block>
  131 +
  132 + </view>
  133 + <view class='clear'></view>
  134 +
  135 +</block>
0 136 \ No newline at end of file
... ...
components/diy_pregoods/diy_pregoods.wxss 0 → 100644
  1 +.flex{
  2 + display: flex;
  3 + align-items: center;
  4 +}
  5 +.top {
  6 + background-color: white;
  7 + height: 70rpx;
  8 + line-height: 70rpx;
  9 + color: #000;
  10 + border-bottom: 2rpx solid #eee;
  11 + padding:0rpx 20rpx;
  12 + display: flex;
  13 + justify-content: space-between;
  14 + font-size: 32rpx;
  15 +}
  16 +
  17 +.s_it {
  18 + width: 100%;
  19 + display: flex;
  20 + background-color: white;
  21 +}
  22 +
  23 +.s_prom {
  24 + width: 100%;
  25 + background-color: white;
  26 + min-height: 200rpx;
  27 +}
  28 +
  29 +swiper {
  30 + display: block;
  31 + height: 400rpx;
  32 +}
  33 +
  34 +.right_k {
  35 + width: 30rpx;
  36 +}
  37 +.right_k image{
  38 + width: 30rpx;
  39 + height: 30rpx;
  40 +}
  41 + .t_left {
  42 + width: 10rpx;
  43 + height: 38rpx;
  44 + background: #c4182e;
  45 + margin-right: 10rpx;
  46 +}
  47 +
  48 +
  49 +.sp {
  50 + min-height: 300rpx;
  51 + width: 100%;
  52 + background-color: white;
  53 + padding: 18rpx;
  54 + display: flex;
  55 +}
  56 +
  57 +.sp .sp_top {
  58 + height: 220rpx;
  59 + min-width: 30%;
  60 +}
  61 +
  62 +.sp .sp_top .s_img {
  63 + width: 210rpx;
  64 + height: 100%;
  65 +}
  66 +
  67 +.sp .sp_top .s_img image {
  68 + width: 210rpx;
  69 + height: 100%;
  70 + position: relative;
  71 + top: -74rpx;
  72 + left: 0rpx;
  73 +}
  74 +
  75 +.sp .sp_top .s_top_kill {
  76 + background-color: #c4182e;
  77 + font-size: 24rpx;
  78 + height: 38rpx;
  79 + line-height: 38rpx;
  80 + left: 6rpx;
  81 + padding: 4rpx 10rpx;
  82 + border-radius: 10rpx;
  83 + z-index: 999;
  84 + position: relative;
  85 + top: -6rpx;
  86 + width: 210rpx;
  87 + color: #fff;
  88 + text-align: center;
  89 +}
  90 +
  91 +.po {
  92 + position: absolute;
  93 +}
  94 +
  95 +.sp .sp_top .s_foot_kill {
  96 + font-size: 20rpx;
  97 + position: relative;
  98 + top: -90rpx;
  99 + width: 210rpx;
  100 + height: 38rpx;
  101 + line-height: 38rpx;
  102 + color: #fff;
  103 + text-align: center;
  104 + background-color: rgba(0, 0, 0, 0.5);
  105 +}
  106 +
  107 +.sp_wz {
  108 + width: 210rpx;
  109 + min-height: 100rpx;
  110 +}
  111 +
  112 +.sp_wz .sp_wzi {
  113 + font-size: 30rpx;
  114 + border-bottom: 2rpx solid #dcdcdc;
  115 + width: 100%;
  116 + text-align: left;
  117 + padding: 4rpx 0;
  118 + overflow: hidden;
  119 + height: 48rpx;
  120 + text-overflow: ellipsis;
  121 + white-space: nowrap;
  122 + line-height: 48rpx;
  123 +}
  124 +
  125 +.sp_wz .sp_jg {
  126 + color: #c4182e;
  127 + font-size: 30rpx;
  128 + overflow: hidden;
  129 + display: inline-block;
  130 + text-overflow: ellipsis;
  131 + white-space: nowrap;
  132 + margin-right: 10rpx;
  133 +}
  134 +
  135 +.sp_wz .sp_jgx {
  136 + color: #adadad;
  137 + text-decoration: line-through;
  138 + font-size: 24rpx;
  139 + overflow: hidden;
  140 + display: inline-block;
  141 + text-overflow: ellipsis;
  142 + white-space: nowrap;
  143 +}
  144 +
  145 +.one {
  146 + margin-left: 14rpx;
  147 +}
  148 +
  149 +.sp .sp_top .s_top1_kill {
  150 + position: absolute;
  151 + background-color: #c4182e;
  152 + font-size: 24rpx;
  153 + height: 38rpx;
  154 + line-height: 38rpx;
  155 + left: 265rpx;
  156 + top: 100rpx;
  157 + padding: 0 10rpx;
  158 + color: white;
  159 + border-radius: 10rpx;
  160 +}
  161 +
  162 +.sp .sp_top .s_top2_kill {
  163 + position: absolute;
  164 + background-color: #c4182e;
  165 + font-size: 24rpx;
  166 + height: 38rpx;
  167 + line-height: 38rpx;
  168 + right: 146rpx;
  169 + top: 100rpx;
  170 + padding: 0 10rpx;
  171 + color: white;
  172 + border-radius: 10rpx;
  173 +}
  174 +
  175 +.sp .sp_top .s_foot1_kill {
  176 + font-size: 20rpx;
  177 + position: absolute;
  178 + top: 270rpx;
  179 + width: 210rpx;
  180 + height: 38rpx;
  181 + line-height: 38rpx;
  182 + color: #fff;
  183 + text-align: center;
  184 + background-color: rgba(0, 0, 0, 0.5);
  185 +}
  186 +
  187 +.po1 {
  188 + position: absolute;
  189 +}
  190 +
  191 +.sp .sp_top .s_foot2_kill {
  192 + font-size: 20rpx;
  193 + position: absolute;
  194 + top: 270rpx;
  195 + width: 210rpx;
  196 + height: 38rpx;
  197 + line-height: 38rpx;
  198 + color: #fff;
  199 + text-align: center;
  200 + background-color: rgba(0, 0, 0, 0.5);
  201 +}
  202 +
  203 +.sp2 {
  204 + width: 100%;
  205 + min-height: 240rpx;
  206 +}
  207 +
  208 +.sp2 .one1 {
  209 + background-color: white;
  210 + height: 285rpx;
  211 + display: flex;
  212 + padding:0rpx 20rpx;
  213 + border-bottom: 6rpx#eee solid;
  214 + align-items: center;
  215 +}
  216 +
  217 +.sp2 .one1 .o1_img {
  218 + width: 220rpx;
  219 + height: 220rpx;
  220 + margin-right: 25rpx;
  221 +}
  222 +
  223 +.o1_right .sp_wzi {
  224 + font-size: 30rpx;
  225 + margin-bottom: 6rpx;
  226 + text-align: left;
  227 + padding: 4rpx 0;
  228 + height: 48rpx;
  229 + overflow: hidden;
  230 + white-space: nowrap;
  231 + text-overflow: ellipsis;
  232 +}
  233 +
  234 +.o1_right .o1_sj_kill {
  235 + height: 60rpx;
  236 + margin-bottom: 10rpx;
  237 + font-size: 28rpx;
  238 +}
  239 +
  240 +.o1_right .o1_sj_kill text {
  241 + background-color: #fdcb08;
  242 + text-align: center;
  243 + border-radius: 10rpx;
  244 + padding: 4rpx;
  245 + margin-left: 6rpx;
  246 +}
  247 +
  248 +.o1_right .sp_jg {
  249 + color: #c4182e;
  250 + font-size: 30rpx;
  251 + overflow: hidden;
  252 + display: inline-block;
  253 + margin-right: 10rpx;
  254 +}
  255 +
  256 +.o1_right .sp_jgx {
  257 + color: #dcdcdc;
  258 + text-decoration: line-through;
  259 + font-size: 26rpx;
  260 + overflow: hidden;
  261 + display: inline-block;
  262 +}
  263 +
  264 +.o1_img image {
  265 + width: 220rpx;
  266 + height: 220rpx;
  267 +}
  268 +.o1_right{
  269 + width: 465rpx;
  270 +}
  271 +.o1_right .wo {
  272 + background-color: #c4182e;
  273 + width: 150rpx;
  274 + height: 50rpx;
  275 + line-height: 50rpx;
  276 + color: white;
  277 + text-align: center;
  278 + font-size: 30rpx;
  279 + border-radius: 14rpx;
  280 +}
  281 +.rob{
  282 + display: flex;
  283 + justify-content: flex-end;
  284 + font-size: 30rpx;
  285 +}
  286 +.money{
  287 + display: flex;
  288 + align-items: center;
  289 +}
  290 +
  291 +.sp .sp_top .s_top_kill.gray{background-color:#bdbdc1;color: #fff;font-weight: normal}
0 292 \ No newline at end of file
... ...