微信小程序模板2

微信小程序模板2

商品列表

详情图片
在这里插入图片描述
利用Component组件实现
good.wxml

<template name='good'>
	<view class='good' bindtap='goodDetail'>
		<!-- 保持背景图片的缩放比例:mode="aspectFill" -->
		<image src="{{good.url}}" mode="aspectFill"></image>
		<!-- 背景遮盖(可去) -->
		<view class='mask'></view> 
		<view class='info'>
			<view class='title'>
				<text>{{good.name}}</text>
			</view>
			<view class='detail'>
				<view class='timeinfo'>
					<text>{{good.address}}</text>
				</view>
				<view class='address' >
					<text>{{good.km}}</text>
				</view>
			</view>
		</view>
		<view class='bottom'>
			<view class='price'>¥{{good.price}}</view>
			<view class='oldprice'>¥{{good.oldprice}}</view>
			<view class='selled'>已售{{good.sell}}</view>
		</view>
	</view>
</template>

good.wxss

.good {
  overflow: hidden;
  position: relative;
  border-radius: 8rpx;
  margin: 25rpx;
}

.good image {
  width: 100%;
  height: 375rpx;
  vertical-align: bottom;
}

.good .mask {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  height: 100%;
  width: 560rpx;
  border-top-left-radius: 8rpx;
  border-bottom-left-radius: 8rpx;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.6)0, rgba(0, 0, 0, 0)100%);
}

.good .info {
  position: absolute;
  top: 30rpx;
  left: 12rpx;
  z-index: 2;
  overflow: hidden;
}

.good .info .title {
  color: #fff;
  font-size: 40rpx;
  margin-bottom: 10rpx;
}

.info .title text {
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 2rpx 2rpx rgba(0, 0, 0, 0.4);
  -webkit-line-clamp: 2;
  display: -webkit-box;
  -webkit-box-orient: vertical;
}

.good .detail {
  position: relative;
  padding-left: 36rpx;
}

.good .detail .timeinfo {
  color: #fff;
  font-size: 22rpx;
  line-height: 1;
}

.good .timeinfo text {
  margin-right: 20rpx;
}

.good .address {
  color: #fff;
  font-size: 22rpx;
  line-height: 1;
  margin-top: 6rpx;
}

.good  .detail::before {
  content: '';
  position: absolute;
  top: 4rpx;
  left: 24rpx;
  width: 6rpx;
  height: 100%;
  background-color: #4abdcc;
}

.good .userinfo {
  position: absolute;
  left: 25rpx;
  bottom: 35rpx;
  z-index: 2;
}

.good .userinfo image {
  width: 50rpx;
  height: 50rpx;
  border-radius: 50rpx;
}

.good .userinfo .username {
  margin-left: 15rpx;
  color: #fff;
  font-size: 20rpx;
  vertical-align: middle;
}

.good .bottom {
  position: absolute;
  left: 25rpx;
  bottom: 20rpx;
  z-index: 2;
  color: #fff;
  font-size: 22rpx;
  display: flex;
  flex-wrap: nowrap;
  flex-direction: row;
  width: 660rpx;
  align-items: flex-end;
}

.bottom .price {
  color: #f63;
  font-size: 30rpx;
  margin-right: 14rpx;
}

.bottom .oldprice {
  color: #fff;
  font-size: 22rpx;
  text-decoration: line-through;
  flex: 1;
}

.bottom .selled {
  color: #ffffff;
  font-size: 22rpx;
}

主页面
index.wxml

<import src="../../components/good/good.wxml"/>

<view class='maylike'>
  <view class='title'>猜你喜欢</view>
  <view class='goods'>
    <block  wx:for="{{goods}}" wx:for-item='good' wx:key='*this' >
      <template is="good" data="{{good:good}}"/>
    </block>
  </view>
</view>

index.wxss

@import '../../components/good/good.wxss';
page{
    background-color: #f0f0f0;
}

.maylike{
    background-color: #fff;
    margin-top: 30rpx;
    padding-top: 20rpx;
}

.maylike .title{
    color: #808080;
    font-size: 28rpx;
    margin-left: 28rpx;
    margin-bottom: -10rpx;
}

地图模板
在这里插入图片描述

1、通过腾讯地图拾取器获取目标单位的坐标
wxml

<view class="map1">
  <map latitude="33.636577" longitude="114.684483"  scale="18" markers="{{markers}}"></map>
</view>

js

Page({
  data: {
    markers:[{
      id:0,
      latitude:"33.636577",
      longitude:"114.684483",
      width:20,
      height:20,
      iconPath:"../images/下载.png",
      title:"周口师范学院至善会堂"
    }]
  },
})

服务器端发送数据到小程序页面
接口地址:http://本地端口/news/getproducts.php
数据格式:
在这里插入图片描述
Code:返回的状态码。 200:表示获取数据成功。
Data:存放数据。 存放商品数据

onLoad(){
    var that = this;
      wx.request({
        url: 'http://10.10.198.12:8088/news/getproducts.php', //仅为示例,并非真实的接口地址

        success (res) {
          
          if(res.data.code == 200){
            that.setData({
                data:res.data
            })
          }else{
            wx.showToast({
              title: '数据传输失败!',
              duration: 8000
            })
          }
        }
      })
    },
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

柠笙

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值