哈喽!大家好,我是HappyGirl快乐女孩,最爱海贼王💞💞💞
是一位爱好技术的【技术Fans】!😜😜😜
💞💞💞 如果有对技术感兴趣的宅友,欢迎关注💞💞💞
❤️❤️❤️感谢各位❤️❤️❤️
————————————————
🎒 🎒 🎒 文章目录 🎒 🎒 🎒
目录
在“计算器”可以使用标准计算器进行基本的算术计算。不光界面跟苹果一样,功能也齐全都是一样的哦。让你的安卓机也是跟苹果机的风格一模一样。
- Page({
- data: {
- value: null, // 上次计算后的结果,null表示没有上次计算的结果
- displayValue: '0', // 显示数值
- operator: null, // 上次计算符号,null表示没有未完成的计算
- waitingForOperand: false // 前一按键是否为计算符号
- },
-
- onLoad: function(options) {
- this.calculatorOperations = {
- 'key-divide': (prevValue, nextValue) => prevValue / nextValue,
- 'key-multiply': (prevValue, nextValue) => prevValue * nextValue,
- 'key-add': (prevValue, nextValue) => prevValue + nextValue,
- 'key-subtract': (prevValue, nextValue) => prevValue - nextValue,
- 'key-equals': (prevValue, nextValue) => nextValue
- }
- },
-
- /* AC操作,一下回到解放前 */
- clearAll() {
- this.setData({
- value: null,
- displayValue: '0',
- operator: null,
- waitingForOperand: false
- })
- },
-
- /* 仅清空当前显示的输入值 */
- clearDisplay() {
- this.setData({
- displayValue: '0'
- })
- },
-
- onTapFunction: function(event) {
- const key = event.target.dataset.key;
-
- switch(key) {
- case 'key-clear':
- if (this.data.displayValue !== '0') {
- this.clearDisplay();
- } else {
- this.clearAll();
- }
-
- break;
-
- case 'key-sign':
- var newValue = parseFloat(this.data.displayValue) * -1
-
- this.setData({
- displayValue: String(newValue)
- })
-
- break;
-
- case 'key-percent':
- const fixedDigits = this.data.displayValue.replace(/^-?\d*\.?/, '')
- var newValue = parseFloat(this.data.displayValue) / 100
-
- this.setData({
- displayValue: String(newValue.toFixed(fixedDigits.length + 2))
- });
-
- break;
-
- default:
- break;
- }
- },
-
- onTapOperator: function(event) {
- const nextOperator = event.target.dataset.key;
- const inputValue = parseFloat(this.data.displayValue);
-
- if (this.data.value == null) {
- this.setData({
- value: inputValue
- });
- } else if (this.data.operator) {
- const currentValue = this.data.value || 0;
- const newValue = this.calculatorOperations[this.data.operator](currentValue, inputValue);
-
- this.setData({
- value: newValue,
- displayValue: String(newValue)
- });
- }
-
- this.setData({
- waitingForOperand: true,
- operator: nextOperator
- });
- },
-
- onTapDigit: function(event) {
- const key = event.target.dataset.key; // 根据data-key标记按键
-
- if(key == 'key-dot') {
- // 按下点号
- if (!(/\./).test(this.data.displayValue)) {
- this.setData({
- displayValue: this.data.displayValue + '.',
- waitingForOperand: false
- })
- }
- } else {
- // 按下数字键
- const digit = key[key.length-1];
-
- if (this.data.waitingForOperand) {
- this.setData({
- displayValue: String(digit),
- waitingForOperand: false
- })
- } else {
- this.setData({
- displayValue: this.data.displayValue === '0' ? String(digit) : this.data.displayValue + digit
- })
- }
- }
- }
- })
- //index.js
- var dataUrl = 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E061FF02C31F716658E5C81F5594D561F2E88B854E81CAAB7806D5E4F103E55D33C16F3FAC506D1AB172DE8600B37E43FAD&fromtag=46'
- var util = require("../../utils/util.js");
-
- //更改数组 第三个参数是对象
- function editArr(arr,i,editCnt){
- let newArr = arr,editingObj = newArr[i];
- for (var x in editCnt){
- editingObj[x]= editCnt[x];
- }
- return newArr;
- }
-
- //获取应用实例
- var app = getApp()
- Page({
- data: {
- userInfo: {},
- curIpt:'',
- showAll:true,
- lists:[],
- curRange:[],
- curBegin:0,
- curFinish:1,
- remind:[]
- },
- //事件处理函数
- bindViewTap: function() {
- wx.navigateTo({
- url: '../logs/logs'
- })
- },
- onLoad: function () {
- var that = this;
- //获取之前保留在缓存里的数据
- wx.getStorage({
- key: 'todolist',
- success: function(res) {
- if(res.data){
- that.setData({
- lists:res.data
- })
- }
- }
- })
- //获取用户信息
- app.getUserInfo(function(userInfo){
- that.setData({
- userInfo:userInfo
- })
- })
- },
- iptChange(e){
- let timeArr = util.setTimeHalf();
- this.setData({
- curIpt:e.detail.value,
- curRange:timeArr
- })
- },
- formReset(){
- this.setData({
- curIpt:'',
- curRange:[]
- })
- },
- formSubmit(){
- let cnt = this.data.curIpt,newLists = this.data.lists,i = newLists.length,begin=this.data.curRange[this.data.curBegin],finish = this.data.curRange[this.data.curFinish];
- if (cnt){
- newLists.push({id:i,content:cnt,done:false,beginTime:begin,finishTime:finish,editing:false});
- this.setData({
- lists:newLists,
- curIpt:''
- })
- }
- },
- beginChange(e){
- this.setData({
- curBegin: e.detail.value,
- curFinish: Number(e.detail.value)+1
- })
- },
- finishChange(e){
- this.setData({
- curFinish: e.detail.value
- })
- },
- //修改备忘录
- toChange(e){
- let i = e.target.dataset.id;
- this.setData({
- lists:editArr(this.data.lists,i,{editing:true})
- })
- },
- iptEdit(e){
- let i = e.target.dataset.id;
- this.setData({
- lists:editArr(this.data.lists,i,{curVal:e.detail.value})
- })
- },
- saveEdit(e){
- let i = e.target.dataset.id;
- this.setData({
- lists:editArr(this.data.lists,i,{content:this.data.lists[i].curVal,editing:false})
- })
- },
- setDone(e){
- let i = e.target.dataset.id,originalDone = this.data.lists[i].done;
- this.setData({
- lists:editArr(this.data.lists,i,{done:!originalDone})
- })
- },
- toDelete(e){
- let i = e.target.dataset.id,newLists = this.data.lists;
- newLists.map(function(l,index){
- if (l.id == i){
- newLists.splice(index,1);
- }
- })
- this.setData({
- lists:newLists
- })
- },
- doneAll(){
- let newLists = this.data.lists;
- newLists.map(function(l){
- l.done = true;
- })
- this.setData({
- lists:newLists
- })
- },
- deleteAll(){
- this.setData({
- lists:[],
- remind:[]
- })
- },
- showUnfinished (){
- this.setData({
- showAll:false
- })
- },
- showAll(){
- //显示全部事项
- this.setData({
- showAll:true
- })
- },
- saveData(){
- let listsArr = this.data.lists;
- wx.setStorage({
- key:'todolist',
- data:listsArr
- })
- }
-
- })
- //index.js
- //获取应用实例
- var net = require("../common/netLoad.js");
- var app = getApp();
- let params = {"device_id":60926495334,"category":"__all__","iid":5034850950};
- import {fetchHeadName,loadHomeCategoryNewsFeed,loadHomeCategoryMoreNewsFeed} from "../common/netTool.js"
- // var net1 = require("../common/netTool.js");
- import dateTimeStamp from '../common/datamissing.js';
-
- Page({
- data: {
- motto: 'Hello World',
- userInfo: {},
- selData:[],
- ishidden:true,
- curpage:0,
- detaildata:[],
- timePublic:[],
- loading:false
- },
-
- onReady:function(){
- this.animation = wx.createAnimation({
- duration:1000,
- timingFunction:"ease",
- })
- },
-
- //排列数据
- listdata(resp){
- // var jsonstr = resp.data.data[0].content;
- var dataArr = [],timepublic = [];
- for (var index of resp.data.data){
- //转换Json字符串=》Json对象
- dataArr.push(JSON.parse(index.content));
- }
- for (var data of dataArr){
- var time = dateTimeStamp(data.publish_time);
- data.publish_time = time;
- }
- console.log(dataArr);
- this.setData({
- detaildata:dataArr,
- loading:true
- });
- },
-
- onLoad: function () {
- console.log('onLoad');
- wx.showNavigationBarLoading();
- let dataArr = [],topname = [];
-
- fetchHeadName().then(resp=>{
- //此时给头部
- // console.log(resp.data.data.data[0].name);
- wx.hideNavigationBarLoading();
- dataArr = resp.data.data.data;
- console.log(dataArr);
- this.setData({
- selData:dataArr
- })
- })
- loadHomeCategoryNewsFeed("__all__").then(resp=>{
- this.listdata(resp);
- })
- },
-
- listClick(e){
- this.setData({
- loading:false
- })
- var idx = e.currentTarget.dataset.idx;
- console.log(idx);
- var selLength = this.data.selData.length;
- for (var i=0; i<selLength; i++){
- if(i == e.target.id){
- this.setData({
- ishidden:false,
- curpage:e.target.id
- });
- break;
- }
- }
- //此时得到刷新列表的数据
- loadHomeCategoryNewsFeed(idx).then(resp=>{
- console.log(resp);
- this.listdata(resp);
- })
- },
- //添加数据
- addData(e){
- wx.showNavigationBarLoading();
- var now = new Date().getTime()/1000;
- var curdata = this.data.detaildata;
- loadHomeCategoryMoreNewsFeed("__all__",now).then(resp=>{
- var arr = resp.data.data;
- var dataArr = [];
- for (var index of arr){
- //转换Json字符串=》Json对象
- dataArr.push(JSON.parse(index.content));
- }
- curdata = curdata.concat(dataArr);
- console.log(curdata);
- wx.hideNavigationBarLoading();
- this.setData({
- detaildata:curdata,
- });
- })
- }
- })
-
-
- //index.js
- //获取应用实例
- var app = getApp()
- Page({
- data: {
- scrollId : 'red',
- isScrollX: true,
- bannerList : [
- {
- url : "../../images/hu_1.png"
- },{
- url : "../../images/huang_1.jpg"
- },{
- url : "../../images/zhao_1.jpg"
- }
- ],
- activeBannerIndex : 0,
- userInfo: {}
- },
- search:function(event){
- wx.navigateTo({
- url:"../search/search"
- });
- },
- //事件处理函数
- bindViewTap: function() {
- wx.navigateTo({
- url: '../logs/logs'
- })
- },
- bindChange : function(e){
- this.setData({activeBannerIndex : e.detail.current});
- },
- onLoad: function () {
- wx.showToast({
- title:"加载中...",
- icon:"loading",
- duration:10000,
- });
- wx.hideToast();
- console.log('onLoad')
- var that = this
- //调用应用实例的方法获取全局数据
- app.getUserInfo(function(userInfo){
-
- //更新数据
- that.setData({
- userInfo:userInfo
- })
- })
- console.log(app.globalData);
- this.setData({'windowWidth' : app.globalData.windowWidth});
- }
- })
- //app.js
- App({
- onLaunch: function () {
- //调用API从本地缓存中获取数据
- var logs = wx.getStorageSync('logs') || []
- logs.unshift(Date.now())
- wx.setStorageSync('logs', logs)
- },
- getUserInfo: function(cb){
- var that = this
- if(this.globalData.userInfo){
- typeof cb == "function" && cb(this.globalData.userInfo)
- }else{
- //调用登录接口
- wx.login({
- success: function () {
- wx.getUserInfo({
- success: function (res) {
- that.globalData.userInfo = res.userInfo
- typeof cb == "function" && cb(that.globalData.userInfo)
- }
- })
- }
- })
- }
- },
- getSystemInfo: function (cb) {
- var that = this
- if(that.globalData.systemInfo){
- typeof cb == "function" && cb(that.globalData.systemInfo)
- }else{
- wx.getSystemInfo({
- success: function(res) {
- that.globalData.systemInfo = res
- typeof cb == "function" && cb(that.globalData.systemInfo)
- }
- })
- }
- },
- globalData:{
- userInfo: null,
- systemInfo: null
- }
- })
微信小程序源码合集8(iOS计算器+备忘录+仿今日头条+仿腾讯视频+艺术).rar-小程序文档类资源-CSDN文库
各位走过路过,不要错过,记得关注我哦