首页 > 编程语言 >#yyds干货盘点#【愚公系列】2022年10月 微信小程序-全局配置属性之入口页面

#yyds干货盘点#【愚公系列】2022年10月 微信小程序-全局配置属性之入口页面

时间:2022-10-10 10:33:49浏览次数:118  
标签:yyds power title 微信 index font data powerList 10

前言

一、entryPagePath

1.入口文件的配置

指定小程序的默认启动路径(首页),常见情景是从微信聊天列表页下拉启动、小程序列表启动等。如果不填,将默认为 pages 列表的第一项。不支持带页面路径参数。

{
  "entryPagePath": "pages/index/index"
}

在这里插入图片描述

2.实际页面的四元数

2.1 index.wxml

<!--index.wxml-->
<view class="container">

  <view class="title">快速了解云开发</view>

  <view class="top_tip">免鉴权接口调用 免部署后台 高并发</view>

  <view class="power" wx:key="title" wx:for="{{powerList}}" wx:for-item="power">
    <view class="power_info" data-index="{{index}}" bindtap="onClickPowerInfo">
      <view class="power_info_text">
        <view class="power_info_text_title">{{power.title}}</view>
        <view class="power_info_text_tip">{{power.tip}}</view>
      </view>
      <image wx:if="{{!power.showItem}}" class="power_info_more" src="../../images/arrow.svg"></image>
      <image wx:if="{{power.showItem}}" class="power_info_less" src="../../images/arrow.svg"></image>
    </view>
    <view wx:if="{{power.showItem}}">
      <view wx:key="title" wx:for="{{power.item}}">
        <view class="line"></view>
        <view class="power_item" bindtap="jumpPage" data-page="{{item.page}}">
          <view class="power_item_title">{{item.title}}</view>
          <image class="power_item_icon" src="../../images/arrow.svg"></image>
        </view>
      </view>
    </view>
  </view>

  <view class="environment" bindtap="onChangeShowEnvChoose">当前环境 {{ selectedEnv.alias }}</view>

  <cloud-tip-modal showUploadTipProps="{{showUploadTip}}"></cloud-tip-modal>

</view>

2.1 index.wxss

/**index.wxss**/

page {
  padding-top: 54rpx;
  background-color: #f6f6f6;
  padding-bottom: 60rpx;
}

.title {
  font-family: PingFang SC;
  font-weight: 500;
  color: #000000;
  font-size: 44rpx;
  margin-bottom: 40rpx;
}

.top_tip {
  font-size: 28rpx;
  font-family: PingFang SC;
  font-weight: 400;
  color: #888888;
  margin-bottom: 28rpx;
}

.power {
  margin-top: 30rpx;
  border-radius: 5px;
  background-color: white;
  width: 93%;
  padding-bottom: 1rpx;
}

.power_info {
  display: flex;
  padding: 30rpx 25rpx;
  align-items: center;
  justify-content: space-between;
}

.power_info_more {
  width: 30rpx;
  height: 30rpx;
  transform: rotate(90deg);
}

.power_info_less {
  width: 30rpx;
  height: 30rpx;
  transform: rotate(270deg);
}

.power_info_text {
  display: flex;
  flex-direction: column;
}

.power_info_text_title {
  margin-bottom: 10rpx;
  font-weight: 400;
  font-size: 35rpx;
}

.power_info_text_tip {
  color: rgba(0, 0, 0, 0.4);
  font-size: 25rpx;
}

.power_item {
  padding: 30rpx 25rpx;
  display: flex;
  justify-content: space-between;
}

.power_item_title {
  font-size: 30rpx;
}

.power_item_icon {
  width: 30rpx;
  height: 30rpx;
}

.line {
  width: 95%;
  margin: 0 auto;
  height: 2rpx;
  background-color: rgba(0, 0, 0, 0.1);
}

.environment {
  color: rgba(0, 0, 0, 0.4);
  font-size: 24rpx;
  margin-top: 25%;
}

2.1 index.json

{
  "usingComponents": {
    "cloud-tip-modal": "/components/cloudTipModal/index"
  }
}

2.1 index.js

// index.js
// const app = getApp()
const { envList } = require('../../envList.js');

Page({
  data: {
    showUploadTip: false,
    powerList: [{
      title: '云函数',
      tip: '安全、免鉴权运行业务代码',
      showItem: false,
      item: [{
        title: '获取OpenId',
        page: 'getOpenId'
      },
      //  {
      //   title: '微信支付'
      // },
       {
        title: '生成小程序码',
        page: 'getMiniProgramCode'
      },
      // {
      //   title: '发送订阅消息',
      // }
    ]
    }, {
      title: '数据库',
      tip: '安全稳定的文档型数据库',
      showItem: false,
      item: [{
        title: '创建集合',
        page: 'createCollection'
      }, {
        title: '更新记录',
        page: 'updateRecord'
      }, {
        title: '查询记录',
        page: 'selectRecord'
      }, {
        title: '聚合操作',
        page: 'sumRecord'
      }]
    }, {
      title: '云存储',
      tip: '自带CDN加速文件存储',
      showItem: false,
      item: [{
        title: '上传文件',
        page: 'uploadFile'
      }]
    }, {
      title: '云托管',
      tip: '不限语言的全托管容器服务',
      showItem: false,
      item: [{
        title: '部署服务',
        page: 'deployService'
      }]
    }],
    envList,
    selectedEnv: envList[0],
    haveCreateCollection: false
  },

  onClickPowerInfo(e) {
    const index = e.currentTarget.dataset.index;
    const powerList = this.data.powerList;
    powerList[index].showItem = !powerList[index].showItem;
    if (powerList[index].title === '数据库' && !this.data.haveCreateCollection) {
      this.onClickDatabase(powerList);
    } else {
      this.setData({
        powerList
      });
    }
  },

  onChangeShowEnvChoose() {
    wx.showActionSheet({
      itemList: this.data.envList.map(i => i.alias),
      success: (res) => {
        this.onChangeSelectedEnv(res.tapIndex);
      },
      fail (res) {
        console.log(res.errMsg);
      }
    });
  },

  onChangeSelectedEnv(index) {
    if (this.data.selectedEnv.envId === this.data.envList[index].envId) {
      return;
    }
    const powerList = this.data.powerList;
    powerList.forEach(i => {
      i.showItem = false;
    });
    this.setData({
      selectedEnv: this.data.envList[index],
      powerList,
      haveCreateCollection: false
    });
  },

  jumpPage(e) {
    wx.navigateTo({
      url: `/pages/${e.currentTarget.dataset.page}/index?envId=${this.data.selectedEnv.envId}`,
    });
  },

  onClickDatabase(powerList) {
    wx.showLoading({
      title: '',
    });
    wx.cloud.callFunction({
      name: 'quickstartFunctions',
      config: {
        env: this.data.selectedEnv.envId
      },
      data: {
        type: 'createCollection'
      }
    }).then((resp) => {
      if (resp.result.success) {
        this.setData({
          haveCreateCollection: true
        });
      }
      this.setData({
        powerList
      });
      wx.hideLoading();
    }).catch((e) => {
      console.log(e);
      this.setData({
        showUploadTip: true
      });
      wx.hideLoading();
    });
  }
});

二、运行效果

在这里插入图片描述

标签:yyds,power,title,微信,index,font,data,powerList,10
From: https://blog.51cto.com/u_15437432/5740906

相关文章

  • 2022年10个用于时间序列分析的Python库推荐
    时间序列是数据点的序列,通常由在一段时间间隔内进行的连续测量组成。时间序列分析是使用统计技术对时间序列数据进行建模和分析,以便从中提取有意义的信息并做出预测的过程......
  • 一次磁盘占用率 100% 的排查记录
    你好,我是悟空。最近遇到一个服务器的问题:磁盘满了,占用率100%~这个问题太常见了,于是先来排查一波是哪些文件占用了大量磁盘。一、排查磁盘占用率100%1.1查看磁盘使用......
  • #yyds干货盘点#
    前序遍历,然后依照图利用二叉树的右半边树构建链表,注意要清空左子树,因为检测机制可能是层序遍历/***<p>给你二叉树的根结点<code>root</code>,请你将它展开为一个单链表:<......
  • #yyds干货盘点#前端架构API层的封装
    上午好,今天为大家分享下个人对于前端​​API​​​层架构的一点经验和看法。架构设计是一条永远走不完的路,没有最好,只有更好。这个道理适用于软件设计的各个场景,前端​​API......
  • [20221008]sql profile优化失效问题.txt
    [20221008]sqlprofile优化失效问题.txt--//生产系统一条sql语句存在性能问题,使用sqlprofile优化固定执行计划,再次出现问题,以前也遇到类似的问题,做一个记录.1.环境:SY......
  • MatrixOne从入门到实践10——物联网平台架构升级
    MatrixOne从入门到实践——物联网平台架构升级公司介绍西安天能软件科技有限责任公司,成立于2018年,公司自成立起集中力量精心打造物联网平台,拥有集自主研发、终端生产、销......
  • 10.3闲话
    本来是不打算写闲话的,不过看见一些有意思的东西。今天在板刷多项式题,就像粉兔说的一样:做多项式题就像()()然而CD说应该把FFT和NTT统一起来然而我对CD说除了初学者应该没......
  • win7升级到win10系统后,node13升级为node16,node版本node-sass版本与不匹配,导致出现npm
    1.错误npmERR!codeERESOLVE系统从win7升级到win10,之前的node版本是13.14.0,现在版本是16.17.1。正常的vue程序无法正常运行。从网上查询得知"node-sass":"^4.14.1"需......
  • 10@lnmp架构服务环境搭建
    文章目录​​LNMP环境搭建​​​​一、LNMP的简述​​​​二、LNMP工作方式​​​​1、访问流程​​​​三、LNMP体系架构搭建​​​​1、nginx安装​​​​2、php安装​​......
  • shell 企业微信机器人发送消息
    目录shell企业微信机器人发送消息企业微信群创建机器人实例shell企业微信机器人发送消息企业微信群创建机器人创建完机器人后我们会获取到一个webhook,通过curl调用we......