123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989 |
- <template>
- <view class="content">
- <!-- <view class="content1">
- <view style='width:70px'>付款方式</view>
- <u-radio-group v-model="dataDetails.advanceFreightService" placement="row">
- <u-radio :customStyle="radioCustomStyle" v-for="(item, index) in radiolist1" :key="index"
- :label="item.name" :name="item.name" @change="radioChange">
- </u-radio>
- </u-radio-group>
- </view> -->
- <view class="content2">
- <view class="flex">
- <view class="title">合同摘要</view>
- <view class="preview" @click="submit(1)">预览合同</view>
- </view>
- <view class='row-between'>
- <view class="gray">发货单位</view>
- <view class="">{{dataDetails.compName?dataDetails.compName:'个人货主'}}</view>
- </view>
- <view class='row-between'>
- <view class="gray">发货地</view>
- <view class="place">
- {{dataDetails.sendPrivate}}{{dataDetails.sendCity}}{{dataDetails.sendArea}}{{dataDetails.sendDetailedAddress}}
- </view>
- </view>
- <view class='row-between'>
- <view class="gray">卸货地</view>
- <view class=" place">
- {{dataDetails.unloadPrivate}}{{dataDetails.unloadCity}}{{dataDetails.unloadArea}}{{dataDetails.unloadDetailedAddress}}
- </view>
- </view>
- <view class='row-between'>
- <view class="gray">货名</view>
- <view class="">{{dataDetails.goodsName}}</view>
- </view>
- <view class='row-between'>
- <view class="gray">距离</view>
- <view class="">约{{dataDetails.distance}}公里</view>
- </view>
- <!-- 司机没有工本费 -->
- <!-- <view class='row-between'>
- <view class="gray">工本费(元)</view>
- <view class="">{{dataDetails.serviceCharge}}</view>
- </view> -->
- <view class="title">
- 完善信息
- </view>
-
- <view class='row-between'>
- <view class="gray">运费(元/车)</view>
- <!-- <view class="">{{dataDetails.freight}}{{dataDetails.illingMethod==0?'元/吨':'元/车'}}</view> -->
- <!-- <view class="flex"><input type="text" placeholder="请输入运费" v-model="dataDetails.freight"
- class="text-align-right yf-input">{{dataDetails.freight}}元/车</view> -->
- <view class="flex">
- <u--input placeholder="请输入运费" border="none" type="number" v-model="dataDetails.freight1"
- inputAlign='right' clearable @input="preMoney"></u--input>
- <!-- <span> 元/车</span> -->
- </view>
- </view>
- <view class='row-between'>
- <view class="gray">车牌号</view>
- <view class="" :style="{'color':dataDetails.carrierInfo.carNo?'#000':'#BBBBBB'}" @click="carClick">
- {{dataDetails.carrierInfo.carNo?dataDetails.carrierInfo.carNo:'请选择车牌号'}}
- <!--< u--input placeholder="请输入车牌号" border="none" readOnly v-model="dataDetails.carrierInfo.carNo"
- inputAlign='right' clearable></u--input> -->
- </view>
- <!-- <view class="flex">
- <input class="" v-model='dataDetails.carrierInfo.carNo' @click.stop="handleShowKeyboard"
- :disabled="true" placeholder="输入车牌号" name="input" style="text-align: right;"></input>
- </view> -->
- </view>
- <view class='row-between'>
- <view class="gray">挂车号(选填)</view>
- <view class="flex">
- <view :style="{'color':dataDetails.trailerNumber?'#000':'#BBBBBB'}">{{dataDetails.trailerNumber?dataDetails.trailerNumber:'自动获取'}}</view>
- <!-- <u--input placeholder="请输入挂车号" border="none" readOnly v-model="dataDetails.trailerNumber"
- inputAlign='right' clearable></u--input> -->
- </view>
- </view>
- <view class='row-between'>
- <view class="gray">装车毛重(吨)</view>
- <view class="flex">
- <u--input placeholder="请输入装车毛重" border="none" type="digit" v-model="dataDetails.grossWeight" inputAlign='right'
- clearable></u--input>
- </view>
- </view>
- <view class='row-between'>
- <view class="gray">装车净重(吨)</view>
- <view class="flex">
- <u--input placeholder="请输入装车净重" border="none" type="digit" v-model="dataDetails.weight" inputAlign='right'
- clearable></u--input>
- </view>
- </view>
- <view class='row-between'>
- <view class="gray">运输开始日期</view>
- <view class="">
- <view @click="dateShow">{{dataDetails.tranStartDate?dataDetails.tranStartDate:'请选择运输开始日期'}}
- </view>
- <u-calendar :show="startShow" mode="single" @confirm="startDate" @close="startShow= false">
- </u-calendar>
- </view>
- </view>
- <view class='row-between'>
- <view class="gray">运输截止日期</view>
- <view class="">
- <!-- <u--input placeholder="请输入内容" border="none" v-model="dataDetails.value" inputAlign='right'
- clearable></u--input> -->
- <view class="" @click="endShow = true">
- {{dataDetails.tranEndDate?dataDetails.tranEndDate:'请选择运输截止日期'}}
- </view>
- <u-calendar :show="endShow" mode="single" @confirm="endDate" @close="endShow= false"></u-calendar>
- </view>
- </view>
- <view class='row-between'>
- <view class="gray">联络人姓名</view>
- <view class="">
- <u--input placeholder="请输入联络人姓名" border="none" v-model="dataDetails.driverName" inputAlign='right'
- clearable></u--input>
- </view>
- </view>
- <view class='row-between'>
- <view class="gray">联络人电话</view>
- <view class="">
- <u--input placeholder="请输入联络人电话" border="none" type="number" maxlength="11"
- v-model="dataDetails.driverPhone" inputAlign='right' clearable></u--input>
- </view>
- </view>
- <view class='row-between'>
- <view class="gray">装车后预付款</view>
- <view class="">
- <u--input placeholder="自动获取,不可编辑" v-if="dataDetails.freightAdvance == 1" border="none"
- v-model="dataDetails.advanceCharge" inputAlign='right' clearable disabled></u--input>
- <u--input placeholder="请输入装车后预付款" v-else border="none" v-model="dataDetails.advanceCharge"
- inputAlign='right' clearable></u--input>
- </view>
- </view>
- <view class='row-between'>
- <view style='width:200px;' class="gray">收款账户</view>
- <view style='word-wrap:break-word;word-break:normal;text-align:right;' class="" @click="collection">
- {{dataDetails.bankDeposit?dataDetails.bankDeposit:"请选择收款账户"}}
- (尾号{{dataDetails.bankCard?dataDetails.bankCard.substring(dataDetails.bankCard.length - 4):""}})
- </view>
- </view>
- </view>
- <view class="wrapper content3">
- <view class="qm-row">
- <view class="handTitle">手写签名</view>
- <image src="@/static/xiangpica@2x.png" mode="widthFix" @click="retDraw" class="retDraw-image"></image>
- <!-- <button @click="retDraw" class="delBtn">重写</button> -->
- </view>
- <view class="handCenter">
- <canvas class="handWriting" :disable-scroll="true" @touchstart="uploadScaleStart"
- @touchmove="uploadScaleMove" canvas-id="handWriting"></canvas>
- </view>
- <view class="handRight">
- </view>
- <view class="handBtn">
- <!-- <image @click="selectColorEvent('black','#1A1A1A')"
- :src="selectColor === 'black' ? '/static/other/color_black_selected.png' : '/static/other/color_black.png'"
- :class="[selectColor === 'black' ? 'color_select' : '', 'black-select']"></image>
- <image @click="selectColorEvent('red','#ca262a')"
- :src="selectColor === 'red' ? '/static/other/color_red_selected.png' : '/static/other/color_red.png'"
- :class="[selectColor === 'red' ? 'color_select' : '', 'black-select']"></image> -->
- <!-- <button @click="saveCanvasAsImg" class="saveBtn">保存</button> -->
- <view @click="$u.throttle(submit(), 1000)" class="saveBtn">提交</view>
- <!-- <button @click="previewCanvasImg" class="previewBtn">预览</button> -->
- <!-- <button @click="subCanvas" class="subBtn">完成</button> -->
- </view>
- </view>
- <u-picker :show="showCarList" :columns="carList" :closeOnClickOverlay='true' @close='selectTypeClose'
- @cancel='selectTypeClose' @confirm='confirmBtn'></u-picker>
- <master-keyboard ref="keyboard" keyboardtype="car" :show="keyShow" :randomNumber="true" :newCar="false"
- :defaultValue="carNumber" @keyboardClick="handleClick"></master-keyboard>
- <u-toast ref="uToast"></u-toast>
- <u-toast ref="uToast"></u-toast>
- </view>
- </template>
- <script>
- import {
- mapState
- } from 'vuex';
- var that;
- import uploadImage from '@/components/ossutil/uploadFile.js';
- export default {
- data() {
- return {
- showCarList: false,
- carList: [],
- carlistCopy: [],
- keyShow: false,
- carNumber: '',
- isScaleStart: false,
- radioCustomStyle: {
- margin: '0 0 0 10rpx'
- },
- canvasName: 'handWriting',
- ctx: "",
- startX: null,
- startY: null,
- canvasWidth: 0,
- canvasHeight: 0,
- selectColor: 'black',
- lineColor: '#1A1A1A', // 颜色
- lineSize: 5, // 笔记倍数
- value: true,
- dataDetails: {
- carrierInfo: {
- loadingAdvancePayment: ''
- },
- serviceCharge: '50'
- },
- radiolist1: [{
- name: '平台垫付运费',
- disabled: false
- },
- {
- name: '无需平台垫付运费',
- disabled: false
- },
- ],
- startShow: false,
- endShow: false,
- contractCheck: false, //判断合同是否提交
- proportion: "", //垫付比例
- status:false,
- };
- },
- computed: {
- ...mapState(['hasLogin', 'userInfo', 'firstAuthentication']),
- },
-
- onShow() {
- let payInfo = uni.getStorageSync("payInfo")
- if (payInfo) {
- this.dataDetails.bankCard = payInfo.bankCard
- this.dataDetails.bankDeposit = payInfo.bankDeposit
- this.dataDetails.bankDepositBranch = payInfo.bankDepositBranch
- this.dataDetails.payeeName = payInfo.payeeName
- } else {
- this.$request.baseRequest('get', '/driverPayeeInfo/getDriverPayee', {
- commonId: that.firstAuthentication.commonId
- }).then(res => {
- if (res.data) {
- this.dataDetails.bankCard = res.data.bankCard
- this.dataDetails.bankDeposit = res.data.bankDeposit
- this.dataDetails.bankDepositBranch = res.data.bankDepositBranch
- this.dataDetails.payeeName = res.data.payeeName
- }
- })
- }
- if (this.dataDetails.carNumber) {
- this.$set(this.dataDetails.carrierInfo, 'carNo', this.dataDetails.carNumber)
- }
- this.preMoney()
- // this.$set(this.dataDetails,'advanceCharge',this.dataDetails.advanceCharge)
- // this.$set(this.dataDetails.carrierInfo,'carNo',this.dataDetails.carNo)
- },
- onLoad(options) {
- this.carList = []
- that = this
- // this.dataDetails = JSON.parse(options.obj)
- // console.log(this.dataDetails.billingMethod==1,this.dataDetails.freight)
- // console.log(this.dataDetails.carNo,this.dataDetails.carrierInfo)
- // this.dataDetails.advanceFreightService = '平台垫付运费'
- this.dataDetails = JSON.parse(decodeURIComponent(options.obj))
- console.log(this.dataDetails)
- if (this.dataDetails.hyCarrierInfo) {
- this.dataDetails.weight = this.dataDetails.hyCarrierInfo.loadingWeight
- this.dataDetails.grossWeight = this.dataDetails.hyCarrierInfo.loadingGrossWeight
- }
- if (this.dataDetails.freightAdvance == 1) {
- this.proportion = this.dataDetails.driverAdvancePayment >= this.dataDetails.ownerAdvancePayment ? this
- .dataDetails.ownerAdvancePayment : this.dataDetails.driverAdvancePayment
- }
- if(this.dataDetails.billingMethod==1){
- this.dataDetails.freight1=this.dataDetails.freight
- }else{
- if(this.dataDetails.driverContract!=1){
- this.dataDetails.freight1=''
- }else{
- this.dataDetails.freight1=this.dataDetails.freight
- }
- }
- // console.log(this.dataDetails)
- this.dataDetails.carrierInfo = {}
- this.ctx = uni.createCanvasContext("handWriting");
- this.$nextTick(() => {
- uni.createSelectorQuery().select('.handCenter').boundingClientRect(rect => {
- this.canvasWidth = rect.width;
- this.canvasHeight = rect.height;
- /* 将canvas背景设置为 白底,不设置 导出的canvas的背景为透明 */
- this.setCanvasBg('#fff');
- this.$request.baseRequest('get', '/commonUser/getSignatureAddress', {
- phone: this.userInfo.phone,
- identification: 1
- }).then(res => {
- if (res.data) {
- if (res.data.signImg) {
- // 获取远程图片,canvas无法直接绘制远程图片
- this.userInfo.signImg = res.data.signImg
- uni.getImageInfo({
- src: res.data.signImg,
- success(res) {
- var ctx = uni.createCanvasContext('handWriting')
- console.log(ctx)
- ctx.drawImage(res.path, 0, 0, 340, 250)
- ctx.save()
- ctx.draw()
- },
- fail(res) {
- console.log("fail -> res", res)
- uni.showToast({
- title: "图片下载异常",
- duration: 2000,
- icon: "none"
- })
- }
- })
- }
- }
- })
- })
- .exec();
- });
- uni.showLoading({
- title: '加载中'
- })
- this.$request.baseRequest('get', '/driverCarInfo/selectDriverCar', {
- // driverId: that.userInfo.driverId,
- commonId: this.userInfo.id
- }).then(res => {
- if (res.code == '200') {
- uni.hideLoading()
- if (res.data.length > 0) {
- let _list = []
- for (let i = 0; i < res.data.length; i++) {
- if (res.data[i].status == '已通过') {
- _list.push(res.data[i].carNumber)
- }
- }
- that.carlistCopy = res.data
- that.carList = [_list]
- }
- } else {
- uni.$u.toast(res.message);
- }
- })
- .catch(res => {
- uni.$u.toast(res.message);
- });
- },
- methods: {
- preMoney() {
- if (this.dataDetails.freightAdvance == 1) {
- this.dataDetails.advanceCharge = this.dataDetails.freight1 * this.proportion?this.proportion:0
- }
- },
- collection() {
- if(!this.dataDetails.carCaptainCommonId){ //carCaptainCommonId没有值 证明他没有车队 可以选择收款账户
- uni.$u.route('/pages/order/bankCard');
- }
- },
- confirmBtn(e) {
- this.dataDetails.carrierInfo.carNo = e.value[0]
- for (let i = 0; i < this.carlistCopy.length; i++) {
- if (e.value[0] == this.carlistCopy[i].carNumber) {
- this.dataDetails.trailerNumber = this.carlistCopy[i].guaCarNumber
- }
- }
- this.showCarList = false
- },
- selectTypeClose() {
- this.showCarList = false
- },
- carClick() {
- this.showCarList = true
- },
- //车牌号弹出键盘
- handleShowKeyboard() {
- if (!this.dataDetails.carrierInfo.carNo) {
- this.carNumber = ''
- } else {
- this.carNumber = this.dataDetails.carrierInfo.carNo
- }
- if (this.$refs.keyboard.open) {
- this.$refs.keyboard.open(false) //true 键盘显示 false 键盘隐藏
- } else {
- this.$refs.keyboard[0].open(false)
- }
- if (this.$refs.keyboard.open) {
- this.$refs.keyboard.open(true) //true 键盘显示 false 键盘隐藏
- } else {
- this.$refs.keyboard[0].open(true)
- }
- },
- //车牌号弹出键盘
- handleClick(e) {
- this.carNumber = e.value
- this.dataDetails.carrierInfo.carNo = e.value //键盘输入值
- },
- dateShow() {
- this.startShow = true
- },
- removeStart() {
- this.startShow = false
- },
- removeEnd() {
- this.endShow = false
- },
- startDate(e) {
- this.startShow = false
- this.dataDetails.tranStartDate = e[0]
- },
- endDate(e) {
- this.dataDetails.tranEndDate = e[0]
- this.endShow = false
- },
- submit(num) {
- this.dataDetails.freight=this.dataDetails.freight1
- let _obj = {}
- if (num == 1) { //预览合同
- _obj.submitFlag = 1
- this.contractCheck = false
- } else { //提交合同
- this.contractCheck = true
- _obj.submitFlag = 2
- if (!that.isScaleStart) {
- if (!this.userInfo.signImg) {
- that.$refs.uToast.show({
- type: 'error',
- message: "手写签名不能为空!",
- })
- return
- }
-
- }
- if (uni.$u.test.isEmpty(that.dataDetails.carrierInfo.carNo)) {
- that.$refs.uToast.show({
- type: 'error',
- message: "车牌号不能为空!",
- })
- return
- }
- if (uni.$u.test.isEmpty(that.dataDetails.grossWeight)) {
- that.$refs.uToast.show({
- type: 'error',
- message: "装车毛重不能为空!",
- })
- return
- }
- if (uni.$u.test.isEmpty(that.dataDetails.weight)) {
- that.$refs.uToast.show({
- type: 'error',
- message: "装车净重不能为空!",
- })
- return
- }
- if(Number(that.dataDetails.weight) > Number(that.dataDetails.grossWeight)){
- that.$refs.uToast.show({
- type: 'error',
- message: "装车净重大于装车毛重!",
- })
- return
- }
- if (uni.$u.test.isEmpty(that.dataDetails.freight)) {
- that.$refs.uToast.show({
- type: 'error',
- message: "运费不能为空!",
- })
- return
- }
- if (uni.$u.test.isEmpty(that.dataDetails.tranStartDate)) {
- that.$refs.uToast.show({
- type: 'error',
- message: "运输起始日期不能为空!",
- })
- return
- }
- if (uni.$u.test.isEmpty(that.dataDetails.tranEndDate)) {
- that.$refs.uToast.show({
- type: 'error',
- message: "运输截止日期不能为空!",
- })
- return
- }
- if (uni.$u.test.isEmpty(that.dataDetails.driverName)) {
- that.$refs.uToast.show({
- type: 'error',
- message: "联络人姓名不能为空!",
- })
- return
- }
- if (uni.$u.test.isEmpty(that.dataDetails.driverPhone)) {
- that.$refs.uToast.show({
- type: 'error',
- message: "联络人电话不能为空!",
- })
- return
- }
- if (uni.$u.test.isEmpty(that.dataDetails.advanceCharge) && that.dataDetails.advanceCharge != 0) {
- that.$refs.uToast.show({
- type: 'error',
- message: "装车后预付款不能为空!",
- })
- return
- }
- if (uni.$u.test.isEmpty(that.dataDetails.bankDeposit)) {
- that.$refs.uToast.show({
- type: 'error',
- message: "收款账号不能为空!",
- })
- return
- }
- }
-
- _obj.trailerNumber = that.dataDetails.trailerNumber
- _obj.tranStartDate = that.dataDetails.tranStartDate
- _obj.tranEndDate = that.dataDetails.tranEndDate
- _obj.contactPersonName = that.dataDetails.driverName
- _obj.contactPersonPhone = that.dataDetails.driverPhone
- _obj.freightCars = that.dataDetails.freight
- // _obj.advanceCharge = that.dataDetails.advanceCharge
- _obj.carNumber = that.dataDetails.carrierInfo.carNo
- _obj.weight = that.dataDetails.weight
- _obj.grossWeight = that.dataDetails.grossWeight
- _obj.advanceCharge = that.dataDetails.advanceCharge
- // _obj.bankCard = that.dataDetails.bankCard
- // _obj.bankDeposit = that.dataDetails.bankDeposit
- // _obj.bankDepositBranch = that.dataDetails.bankDepositBranch
- // _obj.payeeName = that.dataDetails.payeeName
- _obj.id = that.dataDetails.id
- _obj.typeFlag = 2
- _obj.carCaptainAccountNumber = that.dataDetails.carCaptainAccountNumber
- _obj.payeeIdCard = that.dataDetails.payeeIdCard
-
- if(!this.dataDetails.carCaptainCommonId){ //carCaptainCommonId没有值 证明他没有车队长 (有车队长不传收款账户信息)
- _obj.bankCard = that.dataDetails.bankCard
- _obj.bankDeposit = that.dataDetails.bankDeposit
- _obj.bankDepositBranch = that.dataDetails.bankDepositBranch
- _obj.payeeName = that.dataDetails.payeeName
- }
- uni.canvasToTempFilePath({
- canvasId: 'handWriting',
- fileType: 'png',
- quality: 1, //图片质量
- success(res) {
- uploadImage('image', res.tempFilePath, 'appData/',
- result => {
- // 上传成功
- that.dataDetails.cargoOwnerAutograph = result
- _obj.driverAutograph = result
- uni.showLoading({
- title: '加载中',
- mask: true
- })
- that.$request.baseRequest('get', '/orderInfo/setPdf', _obj).then(
- res => {
- if (res.code == 200) {
- uni.hideLoading()
- that.contractSrc = res.data
- uni.downloadFile({
- url: res.data,
- success: function(res) {
- var filePath = res.tempFilePath;
- // uni.openDocument({
- // filePath: filePath,
- // showMenu: true,
- // success: function(res) {
-
- // console.log('打开文档成功');
- // }
- // });
- }
- });
- if (that.contractCheck) { //提交
- that.$refs.uToast.show({
- type: 'success',
- message: "提交成功",
- complete() {
- uni.removeStorageSync(
- "payInfo") //如果要有银行卡缓存就删除
- // uni.$u.route(
- // '/pages/order/confirmLoading', {
- // obj: JSON.stringify(that
- // .dataDetails),
- // });
- uni.setStorageSync('contractdata',that.dataDetails)
- uni.navigateBack({
- delta:1
- })
- // that.upCallback({
- // size: 10,
- // num: 1
- // })
- }
- })
- }
- } else {
- uni.$u.toast(res.message);
- uni.hideLoading()
- }
- })
- .catch(res => {
- uni.hideLoading()
- uni.$u.toast(res.message);
- });
- }
- )
- }
- });
- },
- // change(e){
- // if(this.value){
- // this.$set(this.dataDetails,'advanceFreightService',1)
- // }else{
- // this.$set(this.dataDetails,'advanceFreightService',0)
- // }
- // },
- // 笔迹开始
- uploadScaleStart(e) {
- this.isScaleStart = true
- this.startX = e.changedTouches[0].x
- this.startY = e.changedTouches[0].y
- //设置画笔参数
- //画笔颜色
- this.ctx.setStrokeStyle(this.lineColor)
- //设置线条粗细
- this.ctx.setLineWidth(this.lineSize)
- //设置线条的结束端点样式
- this.ctx.setLineCap("round") //'butt'、'round'、'square'
- //开始画笔
- this.ctx.beginPath()
- },
- // 笔迹移动
- uploadScaleMove(e) {
- //取点
- let temX = e.changedTouches[0].x
- let temY = e.changedTouches[0].y
- //画线条
- this.ctx.moveTo(this.startX, this.startY)
- this.ctx.lineTo(temX, temY)
- this.ctx.stroke()
- this.startX = temX
- this.startY = temY
- this.ctx.draw(true)
- },
- /**
- * 重写
- */
- retDraw() {
- this.ctx.clearRect(0, 0, 700, 730);
- this.ctx.draw();
- //设置canvas背景
- this.setCanvasBg('#fff');
- },
- /**
- * @param {Object} str
- * @param {Object} color
- * 选择颜色
- */
- selectColorEvent(str, color) {
- this.selectColor = str;
- this.lineColor = color;
- },
- //完成
- subCanvas() {
- uni.canvasToTempFilePath({
- canvasId: 'handWriting',
- fileType: 'png',
- quality: 1, //图片质量
- success(res) {
- // console.log(res.tempFilePath, 'canvas生成图片地址');
- uni.showToast({
- title: '以保存'
- });
- //保存到系统相册
- uni.saveImageToPhotosAlbum({
- filePath: res.tempFilePath,
- success(res) {
- uni.showToast({
- title: '已成功保存到相册',
- duration: 2000
- });
- }
- });
- }
- });
- },
- //保存到相册
- saveCanvasAsImg() {
- uni.canvasToTempFilePath({
- canvasId: 'handWriting',
- fileType: 'png',
- quality: 1, //图片质量
- success(res) {
- console.log(res.tempFilePath, 'canvas生成图片地址');
- uni.saveImageToPhotosAlbum({
- filePath: res.tempFilePath,
- success(res) {
- uni.showToast({
- title: '已保存到相册',
- duration: 2000
- });
- }
- });
- }
- });
- },
- //预览
- previewCanvasImg() {
- uni.canvasToTempFilePath({
- canvasId: 'handWriting',
- fileType: 'jpg',
- quality: 1, //图片质量
- success(res) {
- uni.previewImage({
- urls: [res.tempFilePath] //预览图片 数组
- });
- }
- });
- },
- //设置canvas背景色 不设置 导出的canvas的背景为透明
- //@params:字符串 color
- setCanvasBg(color) {
- /* 将canvas背景设置为 白底,不设置 导出的canvas的背景为透明 */
- //rect() 参数说明 矩形路径左上角的横坐标,左上角的纵坐标, 矩形路径的宽度, 矩形路径的高度
- //这里是 canvasHeight - 4 是因为下边盖住边框了,所以手动减了写
- this.ctx.rect(0, 0, this.canvasWidth, this.canvasHeight - 4);
- // ctx.setFillStyle('red')
- this.ctx.setFillStyle(color);
- this.ctx.fill(); //设置填充
- this.ctx.draw(); //开画
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- page {
- background: #fbfbfb;
- height: auto;
- }
- .content1 {
- background: white;
- border-radius: 20rpx;
- margin: 20rpx;
- padding: 30rpx 20rpx;
- display: flex;
- justify-content: space-between;
- .right {
- display: flex;
- }
- }
- .content2 {
- background: white;
- border-radius: 20rpx;
- margin: 20rpx;
- padding: 30rpx 20rpx;
- .title {
- font-size: 36rpx;
- font-weight: 700;
- margin-bottom: 20rpx;
- width: 50%;
- }
- .preview {
- width: 50%;
- text-align: right;
- color: #F5BA3C;
- font-size: 26rpx;
- }
- .row-between {
- margin-bottom: 20rpx;
- }
- .left-text {
- margin-right: 20rpx;
- }
- .yf-input {
- padding-right: 10rpx;
- }
- }
- .content3 {
- background: white;
- border-radius: 20rpx;
- margin: 20rpx;
- padding: 30rpx 20rpx;
- }
- .place {
- width: 80%;
- text-align: right;
- }
- .handCenter {
- border: 4rpx dashed #e9e9e9;
- overflow: hidden;
- box-sizing: border-box;
- height: 500rpx;
- }
- .handWriting {
- background: #F9F9FB;
- width: 340px;
- height: 250px;
- }
- .handRight {
- display: inline-flex;
- align-items: center;
- }
- .handCenter {
- border: 4rpx dashed #e9e9e9;
- flex: 5;
- overflow: hidden;
- box-sizing: border-box;
- }
- .handTitle {
- font-size: 36rpx;
- color: #666;
- font-weight: 700;
- color: #333333;
- margin-bottom: 20rpx;
- }
- .retDraw-image {
- width: 50rpx;
- }
- .qm-row {
- display: flex;
- justify-content: space-between;
- }
- .saveBtn {
- width: 80%;
- background: #F5BA3C;
- color: white;
- text-align: center;
- border-radius: 50rpx;
- padding: 20rpx;
- }
- .handBtn {
- display: flex;
- justify-content: center;
- }
- /*
- .wrapper {
- width: 100%;
- height: 95vh;
- margin: 30rpx 0;
- overflow: hidden;
- display: flex;
- align-content: center;
- flex-direction: row;
- justify-content: center;
- font-size: 28rpx;
- }
- .handBtn button {
- font-size: 28rpx;
- }
- .handBtn {
- height: 95vh;
- display: inline-flex;
- flex-direction: column;
- justify-content: space-between;
- align-content: space-between;
- flex: 1;
- }
- .delBtn {
- position: absolute;
- top: 250rpx;
- left: 0rpx;
- transform: rotate(90deg);
- color: #666;
- }
- .delBtn image {
- position: absolute;
- top: 13rpx;
- left: 25rpx;
- }
- .subBtn {
- position: absolute;
- bottom: 52rpx;
- left: -3rpx;
- display: inline-flex;
- transform: rotate(90deg);
- background: #008ef6;
- color: #fff;
- margin-bottom: 30rpx;
- text-align: center;
- justify-content: center;
- }
- .saveBtn {
- position: absolute;
- top: 375rpx;
- left: 0rpx;
- transform: rotate(90deg);
- color: #666;
- }
- .previewBtn {
- position: absolute;
- top: 500rpx;
- left: 0rpx;
- transform: rotate(90deg);
- color: #666;
- }
- .uploadBtn {
- position: absolute;
- top: 625rpx;
- left: 0rpx;
- transform: rotate(90deg);
- color: #666;
- }
- .black-select {
- width: 60rpx;
- height: 60rpx;
- position: absolute;
- top: 30rpx;
- left: 25rpx;
- }
- .black-select.color_select {
- width: 90rpx;
- height: 90rpx;
- top: 100rpx;
- left: 10rpx;
- }
- .red-select {
- width: 60rpx;
- height: 60rpx;
- position: absolute;
- top: 140rpx;
- left: 25rpx;
- }
- .red-select.color_select {
- width: 90rpx;
- height: 90rpx;
- top: 120rpx;
- left: 10rpx;
- } */
- // /deep/.uni-input-input:disabled {
- // background:#fff;
- // }
- </style>
|