小程序版道歉文案自动生成 道歉神器源码分享

动图预览

请添加图片描述

扫码体验

可使用微信扫下面二维码进行效果预览
请添加图片描述

源码分享

<!--pages/apology/apology.wxml-->
<view class="adContainer">
  <ad  unit-id="adunit-af23500f1a7955ef"></ad> 
</view>
<view class='input'>  


    <input   placeholder="请输入事情,例如多喝热水" model:value="{{thinginput}}" style="outline-style: none ;border: 1px solid #ccc;border-radius: 3px;  height: 90rpx;width: 100%"/> 

    <input   placeholder="请输入昵称,例如冰冰" model:value="{{nicknameinput}}" style="outline-style: none ;border: 1px solid #ccc;border-radius: 3px;  height: 90rpx;width: 100%" /> 
    
</view>
<view class="personinfo">
<radio-group class="radio-group" bindchange="radioChang" data-id="{{item.id}}">
<view class='ra' bindtap='next'>

<radio value="1"  ><text>给男朋友道歉</text></radio>
<radio value="2" checked="true"><text>给女朋友道歉</text></radio>
</view>
</radio-group>
</view>
<view class="mybutton"> 
<button class="btn" style=" padding-bottom: 1rem; height: min-content; border-radius: 20rpx; text-align: center;border:1px solid #11c757" bindtap="generate">生成道歉</button>
<button class="btn" style=" padding-bottom: 1rem; height: min-content; border-radius: 20rpx; text-align: center;border:1px solid #11c757" bindtap="copycontent">复制</button>
<!-- <button class="btn" style=" padding-bottom: 1rem; height: min-content; border-radius: 20rpx; text-align: center;border:1px solid #11c757 "  bindtap="showAd"> 看广告</button> -->
</view>
<scroll-view class="contentRlt">{{resultcontent}}</scroll-view>
<!-- <textarea style="flex-wrap: wrap; width: max-content; height:max-content; border: 1px solid #ccc;border-radius: 3px;  " show-confirm-bar = "{{false}}">{{resultcontent}}</textarea> -->

<!-- <view class="adContainer">
  <ad  unit-id="adunit-af23500f1a7955ef"></ad> 
</view> -->


/* pages/apology/apology.wxss */
.input{
    display: flex;
    flex-direction: column;
    justify-content:space-between
}
.mybutton{
    display: flex;
    flex-direction: row;
    justify-content:space-around
}
.textFour_box{
    width: 100%;
    font-size: 30rpx;
    font-weight: 400;
    color: rgba(87,105,123,1);
    line-height: 26px;
    text-align: justify;
  }
  .btn{
    font-size:35rpx;
  }
  .personinfo{
    display: flex;
    flex-direction: row;
    justify-content:space-around
  }
// pages/apology/apology.js
const app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        thinginput:'',
        nicknameinput:'',
        resultcontent:"",
        isMan:false,
        manData:["老公{name},我们在一起,不是因为将就,不是因为肉体,不是因为金钱。我们在一起,只是因为一个很简单的理由:相爱,愿意一起度过日日夜夜,{thing}这件事,是我一时冲动,希望你能大人不记小人过,饶过小女子,今晚就由臣妾服侍你",
        "嫁给你,做你的妻子。即使你不是一个有钱人,但是在我眼里,嫁给你,我将是这个世界上最富有的新娘。因为你给了我别人无法代替的爱,有了你之后,我时常畅想着我们的未来,一日三餐,有你相伴,想想就美好,亲爱的{name},在{thing}这件事上,是我一时糊涂,我错了,往后的日子里,在做每一件事上,我一定找你先商量,我爱你",
      ],
        rawData:["宝贝{name},我千不该万不该,最不该{thing}。在黎明前,我们都渴望见到曙光;却也同样害怕被烈阳所伤!谈谈吧!愿能携手伴曙光;不愿两伤对烈阳!可爱的{name},我已经为{thing}深刻反省了。我整个晚上都在和你发信息,你一定看见了,你一定是在感动。佛祖云我不入地狱谁入地狱,我不道歉谁道歉。宝贝{name},我不该{thing}的。想起我们曾经有过的甜蜜,所有的气都烟消云散了。这就是真正的亲密无间,任何东西都无法割断——我们彼此的爱。{name}小仙女,{thing}的事的确是我不对。会用行动来说明一切,不会再让你感到伤心与失望,在这我真诚的请你原谅,永远爱你的人!亲爱的{name},我保证下次一定不会{thing}。瞥见你发脾性时,撅起的小嘴,我曾试着,撞豆腐块死,用鼻涕吊死,可都没有乐成。如今就等着你来处置我。",
       
		"{name}宝贝,习惯是从小养成的,{thing}这件事是我错了,改掉这些弊病对我来说就好像别人戒烟、戒酒一样,但我已经痛下决心要改掉那些缺点,并在我们发生矛盾时不再逃避,虽然我不太会哄人,但我会尽力去哄你的,{name}!",
		]



    
    },

    generate(){
      
  
 
      var result =''
      var len = 0;
      if(!this.data.isMan)
      {
        len = this.data.rawData.length-1
        var index =Math.round(Math.random()*(len)); 
        result= this.data.rawData[index]
      }else
      {
        len = this.data.manData.length-1
        var index =Math.round(Math.random()*(len)); 
        result = this.data.manData[index]
      }
    
      
       result = result.replace(/{name}/g,this.data.nicknameinput)
       result = result.replace(/{thing}/g,this.data.thinginput)
     this.setData({
      resultcontent:result
     })

    },
    copycontent(){
        var that = this
        wx.setClipboardData({
          data: that.data.resultcontent,
          success: function (res) {
            wx.getClipboardData({
              success: function (res) {
                wx.showToast({
                  title: '复制成功'
                })
              }
            })
          }
        })
    },
    showAd(){

      let videoAd = null

      // 在页面onLoad回调事件中创建激励视频广告实例
      if (wx.createRewardedVideoAd) {
        videoAd = wx.createRewardedVideoAd({
          adUnitId: 'adunit-3333323e7cafed49'
        })
        videoAd.onLoad(() => {})
        videoAd.onError((err) => {})
        videoAd.onClose((res) => {
            // 用户点击了【关闭广告】按钮
            if (res && res.isEnded) {
              
            } else {
              // 播放中途退出,不下发游戏奖励
            }
        })
      }
      
      // 用户触发广告后,显示激励视频广告
      if (videoAd) {
        videoAd.show().catch(() => {
          // 失败重试
          videoAd.load()
            .then(() => videoAd.show())
            .catch(err => {
              console.log('激励视频 广告显示失败')
            })
        })
      }

    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

      // 在页面onLoad回调事件中创建插屏广告实例
if (wx.createInterstitialAd) {
  app.globalData.interstitialAd = wx.createInterstitialAd({
    adUnitId: 'adunit-38601678c436aa64'
  })
  app.globalData.interstitialAd.onLoad(() => {})
  app.globalData.interstitialAd.onError((err) => {})
  app.globalData.interstitialAd.onClose(() => {})
}
      // 在适合的场景显示插屏广告
if (app.globalData.interstitialAd ) {
  app.globalData.interstitialAd .show().catch((err) => {
    console.error(err)
  })
}

    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    },

    onShareTimeline(){
      
    },
    radioChang (e) {
      if( e.detail.value == 1)
      {
        this.setData({
          isMan:true
        })
      }
     else
      {
        this.setData({
          isMan:false
        })
      }
      },
})
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

老黄叔

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

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

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

打赏作者

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

抵扣说明:

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

余额充值