小程序跳转公众号

简介: 小程序跳转公众号

随着小程序不断的发展,现在个人的小程序也开放了很多功能了,个人小程序直接打开公众号链接。在群里看到的一款小程序,点击可以直接阅读文章了,所以琢磨了一下,写了一些源码

主要代码:

<web-view src="https://mp.weixin.qq.com/s?__biz=MzI2ODUxMzg4Nw==&mid=2247485016&idx=1&sn=e5f60600ea30f669264ddcf5db4fb080&chksm=eaef2168dd98a87ead60eed0f24e799c1befbfe95e341231216af72315c33a56839f92e69ef9&token=29762947&lang=zh_CN#rd"></web-view>

为了达到效果,更加具体的demo

效果如下

weixin.wxml

<navigator url="/pages/search/search" hover-class="changestyle">
  <view class="view-search">
    <input class="input" placeholder-class="input-placeholder" placeholder="输入文章和链接" bindinput="bindSearchInput" />
    <image class="button" src="/images/search.png" bindtap="tapSearch" />
  </view>
</navigator>
<view class="container">
  <view wx:for="{{cardTeams}}" wx:key="{{cardTeam.viewid}}" wx:for-item="cardTeam" class="item" bindtap="bindViewTap">
    <image class="img" src="{{cardTeam.imgsrc}}" mode="scaleToFill"></image>
    <view class="number-wrapper">
      <text class="name">{{cardTeam.name}}</text>
      <view class="count-wrapper">
        <text class="count">{{cardTeam.count}}</text>
      </view>
    </view>
  </view>
</view>

weixin.wxss

.container {
  padding-top: 0;
}
.item {
  width: 100%;
  height: 220rpx;
  position: relative;
  display: flex;
  margin: 10rpx 10rpx;
  border-bottom: 1px solid rgb(197, 199, 199);
}
.item:first-child {
  margin-top: 0;
}
.item .remove {
  width: 60px;
  height: 100%;
  background-color: red;
  position: absolute;
  top: 0;
  right: -60px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.item .number-wrapper {
  height: 100%;
  padding-top: 40rpx;
  flex-direction: column;
  justify-content: space-between;
}
.item .ok {
  width: 60px;
  height: 100%;
  padding-right: 20rpx;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #98f5ff;
}
.item .img {
  width: 150rpx;
  height: 150rpx;
  padding: 20rpx;
}
.number-wrapper .name {
  margin: 10rpx 10rpx 10rpx 10rpx;
  font-size: 39rpx;
  overflow: hidden;
}
.number-wrapper .count-wrapper {
  display: flex;
  align-items: center;
  margin-left: 10rpx;
  font-size: 25rpx;
}
.number-wrapper .count-wrapper .decrease-btn {
  font-size: 30rpx;
}
.number-wrapper .count-wrapper .increase-btn {
  font-size: 30rpx;
}
.number-wrapper .count-wrapper .count {
  margin: 0 1rpx 0 1rpx;
  font-size: 30rpx;
}
.number-wrapper .price-wrapper .people {
  margin-left: 250rpx;
  font-size: 30rpx;
}
/* 搜索框样式 */
.view-search {
  display: flex;
  flex-direction: row;
  height: 70rpx;
  margin: 20rpx;
  padding: 5rpx;
  border: 1px #e4e2e2 solid;
  border-width: thin;
  align-items: center;
}
.input {
  flex: 1;
  height: 60rpx;
}
.input-placeholder {
  color: #999;
}
.button {
  width: 60rpx;
  height: 60rpx;
}

weixin.js

//index.js
//获取应用实例
var app = getApp();
var cardTeams;
Page({
  data: {
    cardTeams: [{
        "viewid": "1",
        "imgsrc": "../../images/win/1.jpg",
        "price": "¥1245",
        "count": "一个40岁老码农的总结,",
        "name": "一个40岁老码农的总结,奋斗",
      }, {
        "viewid": "2",
        "imgsrc": "../../images/win/2.jpg",
        "price": "¥2345",
        "count": "小公司打杂三年,意外拿到",
        "name": "小公司打杂三年,意外拿到美",
      }, {
        "viewid": "3",
        "imgsrc": "../../images/win/3.jpg",
        "price": "¥2345",
        "count": "作为一个有追求的前端程序媛作",
        "name": "作为一个有追求的前端程序媛",
      }, {
        "viewid": "4",
        "imgsrc": "../../images/win/4.jpg",
        "price": "¥2345",
        "count": "女程序媛面试总结:我",
        "name": "女程序媛面试总结:我是这",
      },
      {
        "viewid": "5",
        "imgsrc": "../../images/win/5.jpg",
        "price": "¥2345",
        "count": "前端工作那些年,怎么避?",
        "name": "前端工作那些年,怎么避免",
      }
    ]
  },
  //事件处理函数
  bindViewTap: function() {
    wx.navigateTo({
      url: '../weixinlink/weixinlink'
    })
  },
  onLoad: function() {
    console.log('onLoad:' + app.globalData.domain)
  }
})

文章界面

weixinlink.wxml

<web-view src="https://mp.weixin.qq.com/s?__biz=MzI2ODUxMzg4Nw==&mid=2247485427&idx=1&sn=ebfb8851c6cbb0d40c93f8ecbda83687&chksm=eaef20c3dd98a9d5a19f5ad195888c603c8c819021bab602d11f9aa757b66475d39d23f664c4&token=1408526571&lang=zh_CN#rd"></web-view>

注意:

小程序要和公众号关联,链接才可以打开。

相关文章
|
5月前
|
移动开发 小程序
微信小程序web-view嵌入uni-app H5页面,通过H5页面跳转企业微信客户聊天窗口如何操作?
微信小程序web-view嵌入uni-app H5页面,通过H5页面跳转企业微信客户聊天窗口如何操作?
|
2月前
|
小程序
微信小程序多种跳转页面方式
微信小程序多种跳转页面方式
|
22天前
|
小程序 开发工具
app跳转微信小程序,使用明文scheme拉起
app跳转微信小程序,使用明文scheme拉起
54 4
|
3月前
|
移动开发 小程序 前端开发
php + h5使用 scheme页面跳转微信小程序-其他浏览器一键跳转到微信并打开小程序
php + h5使用 scheme页面跳转微信小程序-其他浏览器一键跳转到微信并打开小程序
65 0
|
5月前
|
小程序
微信小程序实现不同按钮跳转同一个页面显示不同内容
微信小程序实现不同按钮跳转同一个页面显示不同内容
127 0
|
5月前
|
小程序 UED
微信小程序跳转的几种方式
微信小程序跳转的几种方式
|
5月前
|
移动开发 小程序 安全
使用阿里云短信+微信短链接跳转微信小程序
此内容是关于使用阿里云短信带传递参数的微信短链接跳转到微信小程序。首先,需要准备微信开发者工具和一个已认证的小程序。接着,开通云开发并配置云开发权限。然后,配置H5静态网页,包括设置云开发权限和处理不同设备的跳转方式。最后,上传云函数并修改其权限,获取微信短信链接,配置短链接参数,并开通阿里云短信服务以进行测试验证。整个过程涉及到了微信开发者工具、云开发、H5页面配置、云函数的创建和部署以及阿里云短信服务的开通和使用等步骤。
337 0
|
5月前
|
小程序 API 开发者
可以在钉钉小程序中直接跳转到审批单提交页面
【2月更文挑战第19天】可以在钉钉小程序中直接跳转到审批单提交页面
163 5
|
5月前
|
小程序 前端开发 开发者
微信小程序——跳转方式
微信小程序——跳转方式
98 0
|
5月前
|
移动开发 小程序 API
【每周一个小技巧】支付宝小程序内如何跳转生活号文章
【每周一个小技巧】支付宝小程序内如何跳转生活号文章
231 6
下一篇
无影云桌面